Architecture
How the project is structured, how components interact, and how data flows.
High-Level Layering
┌─────────────────────────────────────────────────────┐
│ Urho3D Engine API │
│ (Scene graph, ResourceCache, Input, Audio, UI, …) │
└────────────────────────┬────────────────────────────┘
│ extends
┌─────────────▼──────────────┐
│ GalaxyEggbertApp │ ← entry point / lifecycle
│ (Urho3D::Application) │
└─────────────┬──────────────┘
│ owns
┌─────────────▼──────────────┐
│ GalaxyEggbertGame │ ← main game coordinator
│ (scene, world, subsystems) │
└──────┬────────────┬────────┘
owns │ │ uses
┌─────────────┘ └──────────────────────┐
│ │
▼ Game subsystems ▼ Data layer
Blupi ← player physics, animation World/Chunk/Block
Decor ← object pool, enemies (engine-agnostic)
CameraController ← 3rd-person orbit
HUD ← 2D overlay
PhaseManager ← game-phase state machine
SoundManager ← 93-channel WAV audio
GameData ← 640-byte save file
Main Components
Entry Point — Program.cpp
A single line using the Urho3D macro:
URHO3D_DEFINE_APPLICATION_MAIN(GalaxyEggbertApp)
This macro expands to the platform-appropriate main() / SDL_main() entry point
and constructs a GalaxyEggbertApp instance.
Application — GalaxyEggbertApp
Subclass of Urho3D::Application. Responsible for:
Setup()— window title, resolution, resource paths, log fileStart()— createsGalaxyEggbertGame, subscribes toE_UPDATEeventHandleUpdate()— receives timestep from engine, callsgame_->Update(dt)Stop()— destroys the game object
Source: src/GalaxyEggbert/GalaxyEggbertApp.hpp, .cpp
Game Coordinator — GalaxyEggbertGame
Owns the Urho3D scene and all game subsystems. Responsibilities:
- Creates the 3D scene (Octree, Zone, directional lights)
- Loads and renders world data (block-by-block terrain nodes)
- Manages the
GamePhasestate machine viaPhaseManager - Delegates per-frame logic to phase-specific update methods (
UpdateInit,UpdatePlay, etc.) - Coordinates all subsystems: Blupi, Decor, Camera, HUD, Sound, Save
Source: src/GalaxyEggbert/Game/GalaxyEggbertGame.hpp, .cpp
World Data Model — World / Chunk / Block
Engine-agnostic C++ data model. No Urho3D dependency.
Tested by 54 unit tests in tests/GalaxyEggbert/Worlds/.
Block— 16-bit value: 12-bit type ID + 4-bit metadataChunk— 10×10×10 blocks; palette-compressed bit-packed storageWorld— 10×10×10 chunks (100×100×100 blocks total); save/load API
Public headers: include/GalaxyEggbert/Worlds/
Initialization Flow
Program.cpp
└─ URHO3D_DEFINE_APPLICATION_MAIN(GalaxyEggbertApp)
└─ GalaxyEggbertApp::Setup()
├─ Set window size: 1280×720
├─ Set resource paths: Data;CoreData;Content
└─ Set log: GalaxyEggbert.log
└─ GalaxyEggbertApp::Start()
├─ Create GalaxyEggbertGame
└─ game_->Start()
├─ Determine save path
├─ Read GameData (or defaults)
├─ CreateScene() — Scene + Octree + Zone + Lights
├─ LoadWorld(currentWorld_)
├─ Create PhaseManager, HUD, CameraController, SoundManager
└─ EnterPhase(GamePhase::Init)
Update Flow (per frame)
E_UPDATE event from Urho3D engine
└─ GalaxyEggbertApp::HandleUpdate(dt)
└─ GalaxyEggbertGame::Update(dt)
├─ Check global keys (ESC → quit, F1 → toggle debug)
└─ Switch on current GamePhase:
Play: UpdatePlay(dt)
│ ├─ blupi_->Update(dt) ← physics + animation
│ ├─ camera_->Update(dt) ← camera orbit
│ ├─ decor_->Update(dt) ← enemy + collectible update
│ ├─ Collision/pickup event checks
│ └─ hud_->ShowPlay(...)
Init: UpdateInit(dt) ← gamer select
Pause: UpdatePause(dt)
Win: UpdateWin(dt)
Lost: UpdateLost(dt)
Settings: UpdateSettings(dt)
Shutdown Flow
GalaxyEggbertApp::Stop()
└─ game_.reset()
└─ GalaxyEggbertGame::Stop()
├─ Save GameData to disk
├─ sound_->StopAll()
├─ Reset all subsystems (decor, blupi, phases, hud, camera, sound)
├─ terrainRoot_.Reset()
├─ scene_.Reset()
└─ world_.reset()
Dependency Map
| Component | Depends on |
|---|---|
GalaxyEggbertApp | Urho3D::Application, GalaxyEggbertGame |
GalaxyEggbertGame | Urho3D (all subsystems), World, Blupi, Decor, Camera, HUD, PhaseManager, SoundManager, GameData |
Blupi | Urho3D (Scene, Input, BillboardSet), World (read-only), Tables |
Decor | Urho3D (Scene), ObjectNode |
ObjectNode | Urho3D (BillboardSet, Texture2D) |
CameraController | Urho3D (Scene, Camera node) |
HUD | Urho3D (UI subsystem) |
PhaseManager | Urho3D (UI subsystem, ResourceCache) |
SoundManager | Urho3D (Audio, Sound, SoundSource) |
GameData | C++ stdlib only (no engine dependency) |
World / Chunk / Block | C++ stdlib only (no engine dependency) |
Tables | BlupiAction enum only |
BlockTypes | C++ stdlib only |
Engine Abstraction
Galaxy Eggbert uses the Urho3D API exclusively (no
#ifdef guards for engine differences).
The Nova3D engine is expected to provide the same API and namespace; switching engines requires only a CMake flag change.