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
The DOS game from the 80s re-written in Python from Scratch!

Drugwars The DOS game from the 80s re-written in Python from Scratch! Play in your browser Here Installation Recommended: Using pip pip3 install drugw

Max Bridgland 45 Jan 03, 2023
Flappy-Bird AI - Flappy Bird game with AI

FLAPPY BIRD AI Flappy Bird game solved with neat-python, a Python module based o

1 Jan 07, 2022
Open-source project written in the ursina engine, simulating the popular game Minecraft.

Voxelcraft is an open-source project written in the ursina engine, simulating the popular game Minecraft.

Calinescu Mihai 21 Oct 06, 2022
This is a text-based snake and ladder game .

This is a text-based snake and ladder game .

AKSHAI KRISHNA A 1 Nov 01, 2021
Allows you to email people wordle spoilers. Very beta, not as many features

wordlespoiler Allows you to email people wordle spoilers. Very beta, not as many features How to Use 1.) Make a new gmail account. Go to settings (Man

0 Jan 04, 2023
Projeto Flappy Bird temática doom, projeto python e pygame

Doom-Bird Tecnologias usadas Requisitos para inicializar o jogo: Python faça o download em: https://www.python.org/downloads/ Após instalar o Python d

João Guilherme 1 Dec 08, 2021
A game made similar as space inveders with pygame

space-inveders-pygame a game made similar as space inveders with pygame . . . if you are using it make sure to change audio and imgs file i do no own

Volt_L18 2 Dec 26, 2021
Automatically prepare your Minecraft maps for release

map-prepare Automatically prepare Mineraft map for release. Current state: kinda works Make sure you have backups for your world before running this p

11 Oct 11, 2022
Repository containing documentation about the Minecraft Legacy FUI file structure

Repository containing documentation about the Minecraft Legacy FUI file structure

Miku-666 6 Dec 29, 2022
Database of relevant Minecraft OG usernames

Introduction In this repository we want to collect names and words that get the "OG Name" badge on laby.net. We want the community to be able to contr

LabyMod 19 Dec 02, 2022
Rudimentary CMD based implementation of the Tic Tac Toe game

Packages used: questionary random os (Requires Python 3.8 as walrus operators are used in the script) Contains the .py file (tictactoe.py) and an exe

Ashwin 1 Oct 15, 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
An optimal solution finder for the game Wordle, written in Python

wordle-solver: a nearly-optimal computer player for Wordle Wordle is an interesting word guessing game. This program plays it very well, taking only 3

4 Jun 13, 2022
A base chess engine that makes moves on an instance of board.

A base chess engine that makes moves on an instance of board.

0 Feb 11, 2022
Python Knots and Crosses game, with customizable markers and more!

Knot-and-Crosses Python Knots and Crosses game, with customizable markers and more! Features: Ability to change your marker Ability to change how many

4 Nov 07, 2021
A set of tools to help you with running a Project Zomboid game server (Linux only)

Project Zomboid Server Tools A set of tools to help you with running a Project Zomboid game server (Linux only). Features Install Project Zomboid Dedi

24 Dec 25, 2022
Quantum version of the game Tic Tac Toe.

QTicTacToe Quantum version of the game Tic Tac Toe. This game was inspired by the game at this site. Installation The game requires the qiskit python

1 Jan 05, 2022
Battle of Saiyans: Goku v Vegeta is a 1 v 1, (Player vs CPU) 2D Martial arts fighting game

Battle of Saiyans: Goku v Vegeta is a 1 v 1, (Player vs CPU) 2D Martial arts fighting game inspired by the popular anime series Dragon Ball Z The game

ARZ 3 Feb 16, 2022
Termordle - a terminal based wordle clone in python

Termordle - a terminal based wordle clone in python

2 Feb 08, 2022
Quantum version of the classical Nim game. An automatic opponent allows to game to not be as easy as it seems.

Nim game Running the game To run the program just launch : python3 game.py Rules This game is inspiring from the Nim game. You are 2 players face to f

Michaël 1 Jan 08, 2022