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:

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:

ObjectTypeIconsCycle
2 (enemy A)12–20phase/6 mod 9
3 (enemy B)48–56phase/6 mod 9
4 (bulldozer)65–67table_bulldozer_left, phase/9 mod 8
5 (treasure)0–10 bouncephase/9 mod 22, mirrored
6 (egg)21–28phase/12 mod 8
7 (exit)29–36phase/9 mod 8
16 (spider)69–77phase/3 mod 9
17 (fish)81–83table_poisson_left, phase/6 mod 8
20 (bird)98–105table_oiseau_left, phase/6 mod 8
25 (shield)144–151phase/6 mod 8
33 (blupit tank)248–250table_blupit_left, phase/6 mod 8
49/50/51 (keys)kCle1/2/3 tablesphase/9 mod 12
1 (platform)29static
12 (crate)32static
13 (helicopter)68static
30 (drink)178static

Contact Events (per frame, cleared by ClearEvents())

EventObjectTypesEffect
Exit reached7Level complete
Blupi hit2,3,4,16,17,20,33Life lost
Shield collected25, 13 (placeholder)5 s invincibility
Key collected49,50,51Key count +1
Treasure/item collected5,6,30Collected 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