GalaxyEggbertGame
Main game coordinator — owns the scene, terrain, world, and all subsystems.
Overview
This is the central class of Galaxy Eggbert. It creates and manages:
- The Urho3D 3D scene (scene graph, lighting, sky)
- The voxel world data model (
World) - All game subsystems:
Blupi,Decor,CameraController,HUD,PhaseManager,SoundManager - The
GameDatasave/load - The
GamePhasestate machine dispatch
Source: src/GalaxyEggbert/Game/GalaxyEggbertGame.hpp and .cpp
Public Interface
class GalaxyEggbertGame {
public:
explicit GalaxyEggbertGame(Urho3D::Context* context);
~GalaxyEggbertGame();
void Start();
void Update(float dt);
void Stop();
};
Key Private State
| Member | Type | Purpose |
|---|---|---|
scene_ | SharedPtr<Scene> | Urho3D scene graph |
terrainRoot_ | SharedPtr<Node> | Parent node for all terrain block nodes |
world_ | unique_ptr<World> | Voxel world data |
blupi_ | unique_ptr<Blupi> | Player character |
decor_ | unique_ptr<Decor> | Object pool |
camera_ | unique_ptr<CameraController> | 3rd-person camera |
hud_ | unique_ptr<HUD> | HUD overlay |
phases_ | unique_ptr<PhaseManager> | Phase state machine |
sound_ | unique_ptr<SoundManager> | Audio |
gameData_ | GameData | Save file data |
lives_ | int | Current life count (1–9) |
currentWorld_ | int | Current world number (1–5) |
shieldTimer_ | float | Seconds of shield remaining |
respawnInvincibleTimer_ | float | Seconds of post-respawn invincibility |
tileMatCache_ | unordered_map<uint16_t, Material> | Per-block-type material cache |
kWCX / kWCZ | static constexpr int = 50 | World center offset (block coords) |
kMaxWorld | static constexpr int = 5 | Total world count |
Important Private Methods
| Method | Purpose |
|---|---|
CreateScene() | Creates Urho3D scene with Octree, Zone, lights |
LoadWorld(worldNum) | Loads .vwr or .txt; fallback to demo; spawns terrain nodes; applies sky |
BuildDemoWorld() | Generates procedural demo world when no files exist |
SpawnTerrainNodes() | Iterates world chunks, creates one Box.mdl node per non-air block |
LoadMobileEggbertTerrain(path) | Parses .txt format: header, Decor section, MoveObject entries |
EnterPhase(next) | Transitions to a new GamePhase; reinitializes phase-specific state |
UpdatePlay(dt) | Main gameplay update: player, camera, decor, events, HUD |
UpdateInit(dt) | Gamer-select screen logic |
UpdateSettings(dt) | Settings screen: sound toggle |
SelectGamer(slot) | Loads gamer slot, starts gameplay |
AdvanceToNextWorld() | Increments world, resets per-level counters, loads new world |
ResetLevel() | Game over reset: lives=3, world=1, back to Init |
GetTileMaterial(blockType) | Returns (or creates and caches) material for a block type |
UpdateSkyDome(region) | Updates sky sphere texture based on region index |
Constants
static constexpr int kWCX = 50; // world center X
static constexpr int kWCZ = 50; // world center Z
static constexpr int kMaxWorld = 5; // number of worlds
Lifetime
Created in GalaxyEggbertApp::Start(); destroyed in GalaxyEggbertApp::Stop().
The destructor calls Stop() which saves game data and releases all Urho3D resources.