HUD
Heads-up display — lives, treasure gauge, key icons, and status text.
Overview
HUD manages the 2D overlay UI rendered over the 3D scene.
All UI is built with Urho3D's UI subsystem using Text
and BorderImage elements parented to the root UIElement.
Header: src/GalaxyEggbert/Game/HUD.hpp
Elements
| Element | Type | Content |
|---|---|---|
| Life icons | BorderImage[] | Up to kMaxDisplayedLives = 5 heart icons |
| Treasure gauge | BorderImage | Horizontal fill bar — collected/total |
| Key icons | BorderImage[3] | Three key slots (greyed-out until collected) |
| Status text | Text | Phase messages ("PAUSE", "GAME OVER", etc.) |
| World indicator | Text | "World N" label |
Constants
static constexpr int kMaxDisplayedLives = 5;
When lives_ > 5, all 5 icons are shown fully lit and a numeric indicator
is displayed next to them. (Needs verification — exact overflow behavior.)
API
class HUD {
public:
HUD(Context* context, UIElement* uiRoot);
void SetLives(int lives);
void SetTreasure(int collected, int total);
void SetKeys(int keysCollected); // 0–3
void SetStatusText(const std::string& text);
void SetWorldLabel(int worldNum);
void SetVisible(bool visible);
};
Update Pattern
GalaxyEggbertGame::UpdatePlay() calls HUD setters every frame with current values.
The HUD does not poll state itself — it is purely reactive.
// Inside UpdatePlay(dt)
hud_->SetLives(lives_);
hud_->SetTreasure(decor_->GetCollected(), decor_->GetTotalTreasures());
hud_->SetKeys(decor_->GetKeysCollected());
Asset
Heart and key icons are cut from the sprite sheets loaded from Content/Data/Image/.
Specific icon indices — Needs verification.