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:

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

MemberTypePurpose
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_GameDataSave file data
lives_intCurrent life count (1–9)
currentWorld_intCurrent world number (1–5)
shieldTimer_floatSeconds of shield remaining
respawnInvincibleTimer_floatSeconds of post-respawn invincibility
tileMatCache_unordered_map<uint16_t, Material>Per-block-type material cache
kWCX / kWCZstatic constexpr int = 50World center offset (block coords)
kMaxWorldstatic constexpr int = 5Total world count

Important Private Methods

MethodPurpose
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.