/QTRPG

Primary LanguageGDScript

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. License

About The Quadtree RPG

Quadtree RPG

Building off a Godot official RPG Demo, I used a quadtree data structure to implement a simple search and reveal positional system. This takes the form of a yellow slime you control, that as you move him forward, utilizes this quadtree to search the immediate area to find enemy slimes and reveals them.

The goal of this was to do a from scratch implmentation of an effecient way to locate objects via organizing and storing them by their positions.

What is a Quadtree

You can think about a quadtree visually, which goes well with my usecase for a quadtree using positional data. A quadtree can be a representation of space divided into 4 rectangles or quadrants, each of those quadrants can cotain 4 children or contain another reactangle with 4 quadrants itself. This is an effecient way to store the spatial position of data, based on what quadrant they are in.

For example, we have a bunch of positional points and we want to query if some point p is range. We could compare every point in space to p, the brute force method that would take a long time. Or we could use the quadtree, which find the correct quadrant using time effecient recursive methods, by finding each of the ancestor quadrants until the correct quadrant is found and the children can check if the point is a child of the quadrant (found) or deemed not in range.

Why use a quadtree:

  • A quadtree can take in spatial positioning data and offers good performance for insertion, removal and lookup.
  • In a game, spatial data is constantly changing, you need fast performing structures to handle the retreival and processes of this data.
  • Tha alternative would be a brute force approach of checking all intersections.
  • Great for sparse data sets.

See more about quadtrees and spatial partitioning here:

Quadtrees

Spatial Partition - Game Programming Patterns

Please refer to QT.cs and PlayerQT.cs for my personal code.

Visual Walkthrough

Walkthrough

(back to top)

Built With

(back to top)

Getting Started

This project was written with Godot Engine .NET v4.2.2 in compatibility mode.

Prerequisites

.NET SDK

Installation

Import project via Godot Build via Godot .NET builder

(back to top)

Usage

Use Godot editor play button. Use WASD to move.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)