Extending the Game

Where to add new object types, block types, game phases, and sounds.

Adding a New Object Type

See the full walkthrough in Tutorial: Adding a New Game Object. Summary:

  1. Append enum value to include/GalaxyEggbert/def/ObjectType.hpp (IDs above 203 are safe for new types).
  2. Add icon mapping case in Decor::GetIcon().
  3. Add contact behaviour in Decor::Update() → CheckContact().
  4. Optionally add a new event flag in Decor (e.g., newEvent_) and consume it in GalaxyEggbertGame::UpdatePlay().

Adding a New Block Type

  1. Add a named constant in include/GalaxyEggbert/BlockTypes.hpp:
    static constexpr uint16_t MyBlock = <icon-index-in-object-m.png>;
  2. If the block should be passable (decorative, not collidable), add its ID to the isMobileTransparent() lookup table in BlockTypes.hpp.
  3. If the block originates from mobile-eggbert .txt levels, add a mapping in BlockTypes::fromMobileIconId().
  4. The terrain node spawner (SpawnTerrainNodes()) and material cache (GetTileMaterial()) work automatically for any non-zero block type ID.

Adding a New Game Phase

  1. Add the value to include/GalaxyEggbert/def/GamePhase.hpp.
  2. Add an UpdateXxx(dt) method to GalaxyEggbertGame.
  3. Add a dispatch case in GalaxyEggbertGame::Update(dt):
    case GamePhase::MyPhase: UpdateMyPhase(dt); break;
  4. Trigger it via EnterPhase(GamePhase::MyPhase) from the appropriate event handler.

Adding a New Sound

  1. Place the WAV file at Content/Data/Sound/sound0NN.wav with the next available index.
  2. Add the enum value to include/GalaxyEggbert/def/SoundChannel.hpp:
    SoundChannelNN = NN,
  3. Update SoundManager::kNumChannels if needed.
  4. Call sound_->Play(SoundChannel::SoundChannelNN) from the appropriate location.

Adding a New World

  1. Increment kMaxWorld in GalaxyEggbertGame.
  2. Add Content/Data/Level/scene06.txt (or .vwr).
  3. Update GameData door count if new doors are added.
World count is currently 5 (kMaxWorld = 5). Adding world 6+ requires verifying the GameData door-slot layout stays within the 210-byte per-gamer record.