A lightweight 2D Tower Defense engine/editor written in Python using ImGui for tools/UI and OpenGL for rendering.
Goal: fast level editing, pathfinding testing, tower/enemy logic, wave system — then gradually evolve into a more “engine-like” toolchain.
- Grid-based level editor (Paint mode)
- Brushes: Wall / Path / Tower / Erase / Start / End
- Placement preview + ghost tower (green/red validity + range preview)
- Path Tool mode: create paths from waypoints (A* between waypoints)
- LMB: add waypoint
- Backspace: remove last waypoint
- Enter: apply path
- Esc: clear tool
- A* pathfinding from Start → End
- Computed path overlay visualization
- Tower placement with path-block prevention
- Tower range shown as a real radius circle
- Upgrade / Sell
- Target modes:
- First / Last / Closest / Strongest
- Wave editor: type, count, interval
- Enemy types: normal / fast / tank
- HP bars, rewards, lives system
- Pause / Play / Step
- Time scale: x1 / x2 / x4 + slider
- F5: in-engine console
- DEBUG/INFO/WARN/ERROR filters
- Command history (↑ / ↓)
save_logto file
- Tileset + enemy + tower sprite support (PNG)
- If assets are missing: auto-generated placeholder textures
- TEST-ENGINE/
- assets/
- tiles.png # optional (placeholder used if missing)
- enemy.png # optional (placeholder used if missing)
- tower.png # optional (placeholder used if missing)
- main.py
- requirements.txt
- README.md
- Recommended: Python 3.13
- (Python 3.14 pre-release can break some packages.)
- Windows / Linux / macOS
Windows PowerShell powershell python -m venv .venv .venv\Scripts\activate pip install -r requirements.txt
python main.py - Start the project
- glfw
- PyOpenGL
- imgui
- pillow
- numpy
-
LMB: paint / waypoint (in Path Tool mode)
-
RMB: select tower
-
F5: toggle console
-
Space: pause/play
-
Path Tool: Backspace (pop), Enter (apply), Esc (clear)
Tileset (assets/tiles.png)
A single row with 6 tiles in this order: EMPTY, WALL, PATH, TOWER, START, END
Recommended tile size: 16×16 or 32×32 (any size works; it will be scaled)
Enemy (assets/enemy.png) + Tower (assets/tower.png)
Any square PNG works (e.g. 16×16, 32×32)
If you don’t provide any PNGs, the engine generates placeholder textures automatically.
-
help
-
wave start / wave stop
-
spawn normal|fast|tank
-
save map.json / load map.json
-
save_log log.txt
-
time pause|play|step
-
time scale 2
-
render textures on|off
-
render grid on|off
-
mode paint|path
-
path clear_existing on|off
-
path apply
-
path clear
-
Undo/Redo (Ctrl+Z / Ctrl+Y)
-
Sprite atlas animation (enemy 1×4 frames)
-
Projectile types: splash/slow/poison
-
Better placement tooltip (“why invalid”)
-
Expanded tower inspector (DPS, range preview always-on)
-
Scene system + prefabs
MIT License