An interactive pygame implementation of quadtree spatial quantization

Overview

QuadTree-py

An interactive pygame implementation of quadtree spatial quantization

Contents

Installation

Clone the repo and navigate into it.

git clone https://github.com/ethanavatar/QuadTree-py.git
cd QuadTree-py/

Install pygame if you don't have it already,

python -m pip install pygame

Usage

Run the main module using:

python main.py

You can use:

  • ESCAPE to clear the current board
  • R to create a new random board
  • LEFT MOUSE to add or remove cells

By default, the window is 1200x1200 pixels, the game board is 200x200 cells, and it runs at 60fps. These constants are stored at the top of the locals.py file if you feel like changing them.

Running Example

API Reference

class Point(x : int, y : int)

  • x : X-position
  • y : Y-position

class Rect( x : int, y : int, w : int, h : int)

  • x : X-position
  • y : Y-position
  • w : Width
  • h : Height

class Quad(boundary : Rect, capacity : int)

  • boundary : A Rect representing the size of the initial quad

  • capacity : The number of points allowed in a quad before it subdivides

  • subdivide() -> None Splits the quad into four equally sized quadrants

  • insert(point : Point) -> bool

    Tries to insert a point into the quad. If it doesnt exist within its boundary or its at capacity, it subdivides and calls insert recursively to the newly made quads.

    • point : The Point to insert.
  • query(rect : Rect) - list

    Returns a list of Points that are within the given Rect.

    • rect : A Rect representing the space in which to query point within.
  • draw(surface : pygame.surface, color) -> None

    Draws a wireframe rectangle for the quad, and recursively, for all of its child quads.

    • surface : The pygame.surface to draw the quadtree to.
    • color : The color to draw the wireframe rectangles in.

TODO

  • Make more generic; framework agnostic
Owner
Ethan
Ethan
Navicella cavallo, gioco 2D stile space shooter

Navicella Cavallo Il miglior gioco in circolazione Navicella cavallo รจ un gioco 2D basato sullo stile dei giochi space shooter Come installare Navicel

Matteo 6 Jul 03, 2022
Game Boy emulator written in Python

If you have any questions, or just want to chat, join us on Discord. It is highly recommended to read the report to get a light introduction to Game B

Mads Ynddal 3.7k Dec 30, 2022
Python codes for the classic Hang Man game

Python codes for the classic Hang Man game. The user will be assigned a random word to guess, one character at a time. If the user gets everything right, the program says Well Done!, but if the user

p.katekomol 1 Jan 25, 2022
This is a repository created to run a workshop on Game Theory using the programming language Python and more specifically an open-source software called the Axelrod Python library

Game-Theory-and-Python This is a repository created to run a workshop on Game Theory using the programming language Python and more specifically an op

Nikoleta Glynatsi 136 Dec 01, 2022
Vac-Man in Python

Vac-Man in Python This is my personal version of Vax-man game using python, which is the first assignment of EA Software Engineering Virtual Experienc

ZiXiang Luo 3 Jan 05, 2022
Fully functional BlackJack game with a graphical user interface.

BlackJack Welcome to BlackJack! This game is fully functional, with a casino sound package integrated using Pygame, dynamic game logic developed using

Shwetang Desai 2 Jan 10, 2022
Easy and fun game to play a bit. Written in python

NumGuesser Easy and fun game to play a bit. Written in python

Lodi#0001 4 May 22, 2022
Pygame Raycaster made by me.

Pygame Raycaster made by me.

Sable 0 Jan 10, 2022
Tool for Path of Exile game to automatically scan Archemesis inventory and display related information

poe-archnemesis-scanner Tool for Path of Exile game to automatically scan Archemesis inventory and display related information Features Controls When

70 Nov 10, 2022
Practice the use of the random library to get the user guess the result.

Guessing Game Practice the use of the random library to get the user guess the result. Additional description about the project and its features. Buil

Herbert Orellana 1 Dec 13, 2021
Typing Game : from nob to good

Fast and Curious A game to learn/improve keyboard typing skills. The main idea is to improve your typing skills and at the same time learn fun facts (

Raffaele Fiorillo 7 Jun 13, 2022
Wordle-player - An optimal player for Wordle. Based on a rough understanding of information theory

Wordle-player - An optimal player for Wordle. Based on a rough understanding of information theory

Neill Johnston 3 Feb 26, 2022
Bingo game with python

bingo-game-with-python type of plays possible player vs computer player vs player computer vs computer game is built with 4 objects classes 1.game 2.b

1 Nov 27, 2021
linorobot2 is a ROS2 port of the linorobot package

linorobot2 is a ROS2 port of the linorobot package. If you're planning to build your own custom ROS2 robot (2WD, 4WD, Mecanum Drive) using accessible parts, then this package is for you. This reposit

linorobot 195 Dec 29, 2022
Nerdle - a nerd's approach to solving Wordle

Nerdle - a nerd's approach to solving Wordle

4 Nov 28, 2022
A python script that uses pygame to display fractals.

Pygame-Fractals A python script that uses pygame to display interactive fractals. There are 3 fractals on the script. They can be displayed on the col

michel 2 Feb 09, 2022
A Game of Life implementation in Python

Game of Life in Python (Golipy) Golipy is a simulator of John H. Conway's Game of Life, developed in Python based on the Pygame library. This is a toy

Alber 2 Dec 10, 2021
An old time game Tic-Tac-toe

A Tic Tac Toe Bot This is the code repository for my article on Medium - Playing Games with Python - Tic Tac Toe, where I have tried to take the famou

Jigyanshu 0 Feb 25, 2022
Super Mario Kart November 1991 Prototype Repair by MrL314

Super Mario Kart November 1991 Prototype Repair by MrL314

MrL314 51 Dec 26, 2022
Wordle-prophecy - The comprehensive list of all Wordle answers, past and future

About This repo contains the comprehensive list of all Wordle answers, past and

Hayden Moritz 2 Dec 15, 2022