How quiver-dev/tower-defense-tutorial works
1. Project type and runtime
- This is a Godot 4 2D tower-defense game, organized as a scene-driven project.
- Core content is split between reusable .tscn scenes and behavior .gd scripts.
- Art/audio assets live under assets/, and large binaries are managed with Git LFS.
2. Overall game structure
- The game is built from a small set of major gameplay subsystems: map, spawners, objective, towers, enemies, projectiles, and UI.
- These systems communicate mostly through Godot signals, node references, and shared state rather than a central game service layer.
- The architecture is “scene composition first”: each major gameplay object is its own scene with its own script.
3. Entry points and global state
- project.godot defines the project configuration and scene setup.
- autoloads/global.gd is the main global singleton boundary, used for cross-scene data or persistent game-wide state.
- UI screens such as main menu, pause, and game over are separate scenes, indicating scene switching is part of the control flow.
4. Map and world layer
- maps/map.tscn and maps/map.gd appear to own the playable battlefield and coordinate the major world elements.
- maps/camera/camera2d.* provides a player-controlled camera, separating camera behavior from gameplay entities.
- The map likely anchors navigation/pathing and the placement grid/slots used by towers.
5. Enemy subsystem
- Enemy behavior is centered on entities/enemies/enemy.gd plus concrete enemy scenes for infantry, tanks, and helicopters.
- Enemies are organized with a finite state machine under entities/enemies/states/, including move, shoot, stationary-shoot, and die states.
- Helicopters have their own specialized states (helicopter_move_state.gd, helicopter_shoot_stationary_state.gd), showing enemy-specific behavior extends the common FSM base.
6. Tower subsystem
- Towers are separate scenes for gatling, cannon, and missile variants under entities/towers/.
- entities/towers/tower.gd is the shared tower behavior layer, while tower_slot.gd suggests the map exposes explicit build points.
- tower_costs_json.tres indicates tower economy data is stored as a resource, separating balance data from behavior.
7. Combat and projectile flow
- Towers and some enemies use the shared shooter layer: entities/shooter.gd and entities/shooter_alternating.gd.
- Projectiles are modeled as separate scenes/scripts under entities/projectiles/, with different implementations for bullets, shells, and missiles.
- The main combat flow is: tower or enemy acquires target → shooter emits projectile → projectile collides → hit sound / damage / explosion VFX.
8. Objectives, spawning, and progression
- maps/objective/objective.* represents the defended target or loss condition anchor.
- maps/spawner/spawner.* handles enemy generation and likely the wave/progression cadence.
- This creates the core loop: spawn enemies → traverse map → attack towers/objective → player defends → economy and UI update.
9. Explosion and feedback effects
- entities/explosion_vfx/explosion.tscn is the visual feedback layer for kills and impacts.
- The assets/explosion_vfx/ folders separate default and objective-specific effects, implying feedback varies by event type.
- Sound assets are also event-driven and closely tied to combat actions and impacts.
10. UI layer
- The UI is split into dedicated screens and HUD components: hud, entity_hud, tower_popup, pause, game_over, and main_menu.
- ui/ui_theme.tres shows the project uses Godot themes for consistent styling.
- UI likely bridges player input and game state for tower selection, economy display, pause/menu navigation, and entity inspection.
11. Input and player interaction boundaries
- The player interacts primarily through tower placement, camera control, and menus/HUD rather than direct character control.
- ui/tower_popup.* and entities/towers/tower_slot.* suggest the build flow is: select slot → choose tower → instantiate tower scene.
- This cleanly separates strategic placement UI from world simulation.
12. Asset organization
- Art is grouped by gameplay domain: enemies, towers, projectiles, objective, tiles, explosions, and UI.
- Audio is similarly domain-based, with distinct files for weapon fire, hits, explosions, and unit movement.
- This mirrors the runtime structure, making the asset tree a good proxy for the in-game component architecture.
13. Technical patterns used in the codebase
- The README confirms the project emphasizes FSM AI, signals, inheritance, navigation, CharacterBody2D, and TileMap.
- That means the main architectural boundaries are not services or managers, but reusable scene hierarchies plus state objects.
- Navigation/pathfinding and collision are key engine-level dependencies that shape enemy movement and combat behavior.
14. How the main gameplay systems connect
- The central dependency chain is: map/world provides navigation and build slots, spawner introduces enemies, towers and enemies create projectiles via shooter logic, projectiles resolve hits, and UI/global state reflect economy and game status.
- For an architecture diagram, the most important boundaries are: world simulation, combat actors, projectile/VFX feedback, and presentation/UI.
Main entry points: map.tscn Map · enemy.gd Enemy Base · infantry_t1.tscn Enemy Variants · shooter.gd Shooter
Components 23
Core gameplay
Scene-driven simulation for map, actors, combat, and progression.
- Project · Project settings and startup scene setup.
project.godot - Global · Cross-scene persistent game state and shared data.
autoloads/global.gd - Map · Playable battlefield that hosts navigation, build slots, and world actors.
maps/map.tscn - Camera · Player-controlled 2D camera for world viewing.
maps/camera/camera2d.tscn - Objective · Defended target and loss-condition anchor.
maps/objective/objective.tscn - Spawner · Creates enemy waves and drives progression cadence.
maps/spawner/spawner.tscn - Tower Slot · Explicit placement node used to construct towers.
entities/towers/tower_slot.tscn - Tower Base · Shared tower behavior layer for targeting and firing.
entities/towers/tower.gd - Tower Variants · Concrete gatling, cannon, and missile tower scenes.
entities/towers/gatling_tower.tscn - Enemy Base · Shared enemy behavior and common movement/combat setup.
entities/enemies/enemy.gd - Enemy FSM · Reusable enemy state layer for move, shoot, and die behavior.
entities/enemies/states/move_state.gd - Enemy Variants · Concrete infantry, tank, and helicopter enemy scenes.
entities/enemies/infantry/infantry_t1.tscn - Projectile Base · Shared projectile movement, collision, and impact handling.
entities/projectiles/projectile.gd - Projectile Variants · Bullet, shell, and missile projectile implementations.
entities/projectiles/missile/missile.tscn - Shooter · Shared firing layer used by towers and some enemies.
entities/shooter.gd - Combat VFX · Explosion feedback for hits, kills, and objective damage.
entities/explosion_vfx/explosion.tscn
Presentation
UI screens and styling for menus, HUD, and overlays.
Assets
Domain-organized art and audio referenced by gameplay scenes.
- Enemy Art · Enemy sprites and related visual content.
assets/enemies - Tower Art · Tower sprites and build visuals.
assets/towers - Projectile Art · Bullet, shell, and missile art assets.
assets/projectiles - Sound Bank · Weapon fire, hits, explosions, and unit sounds.
assets/sounds
Connections 29
- Project → Map: starts · Project launches into the main playable scene.
- Global → Map: shared state · Persistent state is available to the world scene.
- Map → Camera: hosts · The battlefield includes the player camera.
- Map → Objective: contains · The battlefield anchors the defended target.
- Map → Spawner: contains · The battlefield owns enemy generation.
- Map → Tower Slot: exposes · Build points are provided by the map.
- Tower Slot → Tower Variants: instantiates · Slots create concrete tower scenes on placement.
- Tower Variants → Tower Base: inherits · Tower scenes share the common tower behavior layer.
- Tower Base → Shooter: fires via · Towers use shared shooter logic to emit projectiles.
- Shooter → Projectile Variants: spawns · Fire control creates projectile scenes.
- Projectile Variants → Projectile Base: inherits · Projectile scenes share common movement and impact logic.
- Enemy Variants → Enemy Base: inherits · Enemy scenes build on the shared enemy script.
- Enemy Base → Enemy FSM: drives · Enemy behavior is organized through state objects.
- Enemy Variants → Shooter: may use · Some enemies reuse the shooter layer for attacks.
- Spawner → Enemy Variants: spawns · Wave generation creates concrete enemies.
- Enemy Base → Objective: attacks · Enemies target the defended objective.
- Tower Base → Enemy Base: targets · Towers acquire enemies as targets.
- Projectile Base → Combat VFX: on hit · Impacts trigger explosion feedback.
- Projectile Base → Sound Bank: plays · Projectile impacts and firing use event sounds.
- Combat VFX → Sound Bank: pairs with · Visual impacts are coupled to audio feedback.
- HUD → Global: reads state · HUD reflects shared game progress and resources.
- Screens → Global: controls flow · Menus and overlays interact with persistent state.
- Screens → Map: switches to · Scene screens transition into gameplay.
- HUD → Theme: styled by · HUD uses the shared UI theme.
- Screens → Theme: styled by · Menu and overlay scenes use the shared UI theme.
- Tower Art → Tower Variants: supports · Tower scenes are backed by domain art.
- Enemy Art → Enemy Variants: supports · Enemy scenes are backed by domain art.
- Projectile Art → Projectile Variants: supports · Projectile scenes are backed by domain art.
- Sound Bank → Shooter: supports · Weapon audio is tied to firing behavior.