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
You might also like...
This is an amazing game make using pygame.

This is an awesome balloon game. It is made in python using Pygame library. It is a project game while learning game development.

 Pendulum Simulation using Pygame
Pendulum Simulation using Pygame

Pendulum project, built using pygame and math modules.

OpenGL experiments with Pygame & ModernGL
OpenGL experiments with Pygame & ModernGL

pygame-opengl OpenGL experiments with Pygame & ModernGL TODO Skybox & Reflections Post-process effects (motion blur, color correction, etc..) Normal m

A short non 100% Accurate Solar System in pygame

solar-system-pygame Controls UP/DOWN for Emulation Speed Control ESC for Pause/Unpause q to Quit c or ESC again to Continue LEFT CLICK to Add an orbit

A Street Fighter game in Pygame
A Street Fighter game in Pygame

What is Street Fighter? Street Fighter, commonly abbreviated as SF or スト, is a Japanese competitive fighting video game franchise developed and publis

Simple car game written in PyGame

Welcome to CarGame 👋 Car Game written in PyGame! NOTE: This is still new and there may be stuff broken... 🏠 Homepage Install install pygame by typin

A Pygame application which generates mazes using randomized DFS (Depth-First-Search)
A Pygame application which generates mazes using randomized DFS (Depth-First-Search)

Maze-Generator-with-Randomized-DFS A Pygame application which generates mazes using randomized DFS (Depth-First-Search)-(Iterative implementation). Ra

FlappyBird game with python and pygame

FlappyBird game with python and pygame

A Gomoku game GUI using pygame where the user can choose to play against another player or an AI using minimax with alpha-beta pruning

Gomoku A GUI based Gomoku game using pygame where the user can choose to play against another player or an AI using minimax with alpha-beta pruning. R

Owner
Ethan
Ethan
PyGame-Tutorial - Refrence for building games in pygame

PyGame-Tutorial How to build games using the python library PyGame End result Ho

St. Mark's Computer Science Club 2 Jan 9, 2022
An interactive pygame implementation of Conway's Game of Life

Game of Life An interactive pygame implementation of Conway's Game of Life Installation Clone the repo and navigate into it. git clone https://github.

Ethan 1 Dec 5, 2021
A simple pygame implementation of the LOGO programming language.

LOGO-py A simple pygame implementation of the LOGO programming language. Latest Version Notes Fixed a bug where penup/pendown would not work properly.

Ethan Evans 1 Dec 5, 2021
A pygame implementation of John Conway's Game of Life

Game of Life A Pygame Simulation This is a Pygame implementation of the famous Conway's Game of Life. The game features a set of very simple rules: An

null 1 Jan 6, 2022
A Pygame game made in 48 hours

Flappuccino Flappuccino is a game created in 48 hours for the PyGame Community New Years Jam using Python with Pygame. Screenshots Background Informat

PolyMars 242 Jan 2, 2023
Quiz game made entirely with python and pygame for school work

Tabela de conteúdo Descrição Como instalar Linguagens usadas Contribuidores Créditos Problemas com o jogo? Contate-nos Descrição Quiz feito inteiramen

null 3 Apr 12, 2022
Recreation of HexGame in Pygame. More features will come soon !

Hex with Pygame Historical point of view What Are the rules of this game ? Some Strategies and tips The algorithm for the Win Other fonctionnalities W

null 4 Mar 26, 2022
This is a simple game made using pygame.

Ball breaker This is a simple game made using pygame game view The game view have been updated wait for the new view to be uploaded Game_show.mp4 Lear

Rishikesh Kumar 3 Nov 5, 2021
A simple matrix code rain created using Python with Pygame.

Matrix4_code_rain A simple matrix code rain created using Python with Pygame. To run the code you will need Pygame and MS Mincho font. Create a projec

null 7 Nov 6, 2022
null 3 Oct 22, 2021