🐣 Mobile Eggbert

API Reference: Key Classes

Detailed documentation of the most important C++ classes in Mobile Eggbert. For enum types, see Enumerations.

Decor

File: include/WindowsPhoneSpeedyBlupi/Decor.hpp, src/WindowsPhoneSpeedyBlupi/Decor.cpp (~9400+ lines)

The core of the entire game simulation. Owns the world grid, all moving objects, the player character, physics, collision, AI, camera, rendering, and win/loss detection.

Player State Fields

FieldTypeDescription
m_blupiX, m_blupiYintPlayer position in game-space pixels
m_blupiActionBlupiActionCurrent animation state
m_blupiDirDirectionFacing direction
m_blupiPhaseintAnimation frame index into Tables
m_blupiChannelPixmapChannelWhich sprite sheet variant is in use
m_blupiHelicoboolCurrently in helicopter
m_blupiJeepboolCurrently in jeep
m_blupiTankboolCurrently in tank
m_blupiSkateboolCurrently on skateboard
m_blupiSurfboolAt water surface
m_blupiNageboolSwimming in deep water
m_blupiOverboolCurrently in hovercraft
m_blupiInvertboolControls are inverted
m_blupiCloudboolCloud invisibility active
m_blupiShieldintShield timer (100 ticks when active)
m_blupiPhantomintInvisibility timer
m_blupiCleDoorKeyFlagsKeys currently held
m_blupiBulletintTank ammo count
m_blupiDynamiteintDynamite count

Key Methods

MethodDescription
InitDecor()Initializes / resets the world grid
InitGamer()Initializes player state for a new game
MoveStep()Per-frame update: player physics, object AI, collision
Build()Renders the world tiles and all objects
DrawInfo()Renders the HUD (lives, keys, power-up indicators)
IsLave(x, y)Returns true if tile at (x,y) is lava
IsDeepWater(x, y)Returns true if tile is deep water
IsDoor(x, y)Returns true if tile is a locked door
IsBridge(x, y)Returns true if tile is a fragile bridge

World Grid

struct Cellule { short icon; };

Cellule m_decor[100][100];     // base tile layer
Cellule m_bigDecor[100][100];  // secondary decorative layer

Game1

File: include/WindowsPhoneSpeedyBlupi/Game1.hpp, src/WindowsPhoneSpeedyBlupi/Game1.cpp

The top-level XNA game class. Inherits CNA's Game base. Owns all subsystems, drives the phase state machine, handles button callbacks (WM_BUTTON*), and the cheat system.

Lifecycle

Initialize()   → platform/window setup
LoadContent()  → sprite sheets, sounds, level data
Update()       → input, phase state machine, game logic
Draw()         → SpriteBatch rendering pass

Phase Transitions

Game1::SetPhase(Phase p) centralizes all side-effects of phase changes: asset loading, InputPad reconfiguration, fade animations. Never set the phase field directly — always call SetPhase().

Button Dispatching

UI button presses arrive as named ButtonGlyph enum values to Game1::HandleButton(ButtonGlyph), which dispatches to the appropriate handler based on the current phase.


Pixmap / IPixmap

File: include/WindowsPhoneSpeedyBlupi/Pixmap.hpp, IPixmap.hpp

IPixmap is the interface. Pixmap is the concrete implementation using CNA's SpriteBatch.

Channel Management

17 named channels (1–17) each correspond to a loaded texture. Key operations:

  • LoadChannel(PixmapChannel, path) — load a PNG into a channel
  • DrawIcon(channel, icon, x, y, …) — draw a sprite cell
  • SetScrollOffset(x, y) — set camera scroll position

Sound / ISound

File: include/WindowsPhoneSpeedyBlupi/Sound.hpp, ISound.hpp

Manages 93 WAV slots via CNA's audio layer (SDL3_mixer). Volume and stereo balance are controlled via per-channel tables in Sound.cpp.

Key Operations

  • PlaySound(SoundChannel, x) — play a sound with automatic panning based on screen X position
  • StopAll() — stop all audio (called on phase transitions)
  • SetMasterVolume(float) — global volume control

InputPad

File: include/WindowsPhoneSpeedyBlupi/InputPad.hpp, src/WindowsPhoneSpeedyBlupi/InputPad.cpp

Abstracts touch, keyboard, and accelerometer input into the two values Decor needs: a Direction and a KeyPressFlags bitmask.

Input Sources

  • Touch: on-screen buttons (PlayJump, PlayAction, PlayDown, D-pad)
  • Keyboard: arrow keys → Direction, Z/X/C or Space → Jump/Fire/Down
  • Accelerometer: tilt → Direction (optional, toggle in settings)

InputPad is reconfigured on each phase transition (e.g., touch buttons are hidden during menus, shown during Play).


GameData

File: include/WindowsPhoneSpeedyBlupi/GameData.hpp, src/WindowsPhoneSpeedyBlupi/GameData.cpp

Manages a flat 640-byte binary array persisted to disk (or IndexedDB on web). Three gamer slots of 210 bytes each, plus a 10-byte header.

Key Accessors

AccessorDescription
getSelectedGamerProperty()Currently active gamer slot (0–2)
setSelectedGamerProperty(int)Switch active gamer slot
getNbViesProperty()Lives remaining for active gamer
setNbViesProperty(int)Set lives remaining
getLastWorldProperty()Last level reached by active gamer
setLastWorldProperty(int)Set last level reached

Serialized/deserialized via Worlds::ReadGameData() / Worlds::WriteGameData(). See Data Formats: Save Data for the full layout.


Worlds

File: include/WindowsPhoneSpeedyBlupi/Worlds.hpp, src/WindowsPhoneSpeedyBlupi/Worlds.cpp

Handles all file I/O for level data and save data.

Key Operations

MethodDescription
ReadWorld(int worldNum, Decor&)Load a level from worlds/worldNNN.txt
WriteWorld(int worldNum, Decor&)Save level state back to file
ReadGameData(GameData&)Load save data from persistent storage
WriteGameData(GameData&)Write save data to persistent storage

Tables

File: include/WindowsPhoneSpeedyBlupi/Tables.hpp, src/WindowsPhoneSpeedyBlupi/Tables.cpp

Two static data structures:

  1. Animation table — 2911 entries mapping (BlupiAction, phase)(channel, icon, nextPhase). Drives all character animation without per-action branching in Decor.
  2. Cheat code list — 22 string entries used by Game1::CheatAction().
struct TableEntry {
    PixmapChannel channel;
    short         icon;
    short         nextPhase;
};

extern const TableEntry AnimTable[2911];
extern const char* CheatCodes[22];

Text

File: include/WindowsPhoneSpeedyBlupi/Text.hpp, src/WindowsPhoneSpeedyBlupi/Text.cpp

Bitmap font renderer using icons/text.png (32×32 px cells, PixmapChannel::Text). Used to render level names, score displays, and HUD text.


TinyPoint

File: include/WindowsPhoneSpeedyBlupi/TinyPoint.hpp

Simple 2D integer point. Standard (x, y) field order.

struct TinyPoint {
    int x;
    int y;
};

TinyRect

File: include/WindowsPhoneSpeedyBlupi/TinyRect.hpp

Non-Standard Field Order! TinyRect fields are Left, Right, Top, Bottom — not Left, Top, Right, Bottom as in most frameworks. The constructor is TinyRect(left, right, top, bottom). Passing arguments in the wrong order produces silent geometry bugs that are very hard to diagnose.
struct TinyRect {
    int Left;
    int Right;   // ← NOT Top
    int Top;     // ← NOT Right
    int Bottom;

    TinyRect(int left, int right, int top, int bottom);
};