Decor
Game object pool — enemies, collectibles, moving platforms, and collision events.
Overview
Decor is a partial port of the mobile-eggbert Decor.cpp object system.
It manages a fixed-size pool of up to 100 game objects and handles:
- Linear patrol movement between start and end points
- Animation phase update and icon selection
- Blupi–object contact detection (0.85 unit radius)
- Event flags: exit reached, Blupi hit, shield collected, treasures, keys, platform carry
Sources: src/GalaxyEggbert/Game/Decor.hpp and .cpp
Object Pool
static constexpr int kMaxObjects = 100;
struct Object {
ObjectType type;
Vector3 posStart, posEnd, pos;
float speed; // units/s
int direction; // +1 or -1
int animPhase;
bool active;
unique_ptr<ObjectNode> node;
};
Public Interface
class Decor {
public:
Decor(Context* context, Scene* scene);
// Place a game object. posEnd left default → stationary.
void PlaceObject(ObjectType type, Vector3 pos,
Vector3 posEnd = Vector3(0,-999,0), float speed = 1.5f);
void Update(float dt, Vector3 blupiPos);
bool WasExitReached() const;
bool WasBlupiHit() const;
bool WasShieldCollected() const;
int GetCollected() const;
int GetTotalTreasures() const;
int GetKeysCollected() const;
Vector3 GetPlatformDelta() const;
void ClearEvents();
};
GetIcon() — Animation Icons
Returns the element.png icon index for an object based on its type and animPhase.
Icon tables are ported directly from mobile-eggbert Tables.cpp:
| ObjectType | Icons | Cycle |
|---|---|---|
| 2 (enemy A) | 12–20 | phase/6 mod 9 |
| 3 (enemy B) | 48–56 | phase/6 mod 9 |
| 4 (bulldozer) | 65–67 | table_bulldozer_left, phase/9 mod 8 |
| 5 (treasure) | 0–10 bounce | phase/9 mod 22, mirrored |
| 6 (egg) | 21–28 | phase/12 mod 8 |
| 7 (exit) | 29–36 | phase/9 mod 8 |
| 16 (spider) | 69–77 | phase/3 mod 9 |
| 17 (fish) | 81–83 | table_poisson_left, phase/6 mod 8 |
| 20 (bird) | 98–105 | table_oiseau_left, phase/6 mod 8 |
| 25 (shield) | 144–151 | phase/6 mod 8 |
| 33 (blupit tank) | 248–250 | table_blupit_left, phase/6 mod 8 |
| 49/50/51 (keys) | kCle1/2/3 tables | phase/9 mod 12 |
| 1 (platform) | 29 | static |
| 12 (crate) | 32 | static |
| 13 (helicopter) | 68 | static |
| 30 (drink) | 178 | static |
Contact Events (per frame, cleared by ClearEvents())
| Event | ObjectTypes | Effect |
|---|---|---|
| Exit reached | 7 | Level complete |
| Blupi hit | 2,3,4,16,17,20,33 | Life lost |
| Shield collected | 25, 13 (placeholder) | 5 s invincibility |
| Key collected | 49,50,51 | Key count +1 |
| Treasure/item collected | 5,6,30 | Collected count +1; object removed |
Platform Carry
For ObjectType1 (moving platform): if Blupi is within 0.85 units horizontally
and 1.5 units vertically of the platform, the platform's XZ movement delta this frame
is accumulated in platformDelta_ and applied to Blupi via ApplyExternalDelta().
Limitations
- Partial port of mobile-eggbert Decor. Many object types (vehicles, advanced AI, projectiles) are not yet implemented.
- No tile-triggered events (door opening, bridge building) yet.
- Object removal via
obj.node->Remove()is permanent — no respawning on level reset without full reload.