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
An algorithm to reach a correlated equilibrium in multiplayer games.

Correlatedpy: a python library for distributed learning of correlated equilibrium in multiplayer strategic games. View Demo · Report Bug · Request Fea

Omar Boufous 2 Feb 01, 2022
This project is an exciting fun game for beginners to build up

This project is an exciting fun game for beginners to build up. The program generates a random number from 1 to 10, or 1 to 100 any range that is specified and the user must guess the number after a

PyLaboratory 0 Feb 07, 2022
Simple darts game using Tkinter and sqlite3. Also associated with Python.

Ever wanted to play a simple and fun game before, and it even keeps a database of your score? Well here it is!! Introducing; Darts! A simple and fun g

an aspirin 2 Dec 19, 2021
This is Minesweeper coded in Python. It has almost all features from the main game

Minesweeper This is Minesweeper coded in Python. It has almost all features from the main game Use right click to open tile, right click on an open ti

3 Jul 12, 2022
A first-person shooting game developed by using OpenGL

OpenGL-MazeSurvivor-FirstPerson Shooting Game This application named ‘MAZE SURVIVOR’ is a first-person shooting game that finished within a month. It

JunHong 2 Jan 04, 2023
A comprehensive, feature-rich, open source, and portable, collection of Solitaire games.

PySol Fan Club edition This is an open source and portable (Windows, Linux and Mac OS X) collection of Card Solitaire/Patience games written in Python

Shlomi Fish 368 Dec 28, 2022
Trio Assembly Snakemake Workflow

Trio Assembly Snakemake Workflow Input HiFi reads for child in bam format Either

Juniper A. Lake 1 Jan 28, 2022
Vac-Man in Python

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

ZiXiang Luo 3 Jan 05, 2022
🕹️ Jeu Azul en Python avec 4 IAs 🤖 implémentées, jouable de 1 à 4 joueurs

Projet jeu Azul 🕹️ Jeu Azul en Python avec 4 IAs 🤖 implémentées, jouable de 1 à 4 joueurs Par : Berachem MARKRIA et Tristan MARTINEZ Projet réalisé

Berachem Markria 2 Jun 07, 2022
Multiplayer 2D shooter made with Pygame

PyTanks This project started as a one day project with two goals: Create a simulated environment with as much logic as possible written in Numpy, to o

Felix Chippendale 1 Nov 07, 2021
An all-inclusive Python framework for the Riot Games League of Legends API. We focus on making the data easy and fun to work with, while providing all the tools necessary to create a website or do data analysis.

Cassiopeia A Python adaptation of the Riot Games League of Legends API (https://developer.riotgames.com/). Cassiopeia is the sister library to Orianna

Meraki Analytics 473 Jan 07, 2023
A fun, casual and strategic game made using Python!

Steve's Pixels A fun, casual and strategic game made using Python! Prerequisites See requirements.txt Demo video demo.mp4 Usage python -m steves_pixel

Jaivardhan Bhola 9 Sep 17, 2022
SnailJumper - A game that is developed as an assignment for Computer Intelligence course

Snail jumper Neuroevolution game assignment. Fall 2021 - Computer Intelligence.

Soroush Mehraban 22 Aug 22, 2022
Just a simple Tic Tac Toe game, built with Python

TicTacToe Author: Gabriel Lima Table of Contents About Getting Started Linux Windows About This is one of the first projects I built when I first star

1 Nov 28, 2021
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
Games: Create interesting games by pure python.

Create interesting games by pure python.

4.2k Jan 06, 2023
Generates and prints proxies for the card game Magic: the Gathering

MTG-Proxy-Generator This program generates proxies for the card game Magic: the Gathering. These proxies can then be printed off and used. These copie

Carl L. 1 Jan 31, 2022
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
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 09, 2022
Creates a landscape with more accurate river generation in Minecraft version 1.12 using python.

MinecraftLandRiverGen View the following youtube video to set up a world that can interact with the python programs

23 Dec 25, 2022