GameData

640-byte binary save file — binary-compatible with mobile-eggbert.

Overview

GameData is a plain-data struct that holds all persistent player progress. The 640-byte layout is identical to the original mobile-eggbert save format, allowing interoperability with save files from that game. Three gamer slots are supported.

Header: src/GalaxyEggbert/Game/GameData.hpp

Constants

static constexpr int kTotalLength = 640;   // total file size in bytes
static constexpr int kMaxGamer    =   3;   // number of gamer slots

Binary Layout

All values are single bytes (uint8_t) unless noted.

OffsetFieldValues / Notes
0versionFormat version byte
1reservedPadding byte
2selectedGamer0–2, last active slot
3sounds0 = muted, 1 = enabled
4jumpRight0/1 control preference
5autoZoom0/1
6accelActive0/1 (accelerometer, mobile)
7accelSensitivitySensitivity level 0–9
8–9reservedAlignment padding
10 + g×210nbVies[g]Lives remaining for gamer g (0–2)
11 + g×210lastWorld[g]Highest world reached (1–5)
20 + g×210doors[g][0..199]200 bytes: per-door completion flags
Note: The gamer sub-record is 210 bytes (3 × 210 = 630), plus 10 bytes of global header = 640 total.

API

struct GameData {
    static constexpr int kTotalLength = 640;
    static constexpr int kMaxGamer    = 3;

    uint8_t data[kTotalLength] = {};

    void load(const std::filesystem::path& path);
    void save(const std::filesystem::path& path) const;

    // Convenience accessors (index into data[])
    uint8_t&       version()          { return data[0]; }
    uint8_t&       selectedGamer()    { return data[2]; }
    uint8_t&       sounds()           { return data[3]; }

    uint8_t&       nbVies(int g)      { return data[10 + g * 210]; }
    uint8_t&       lastWorld(int g)   { return data[11 + g * 210]; }
    uint8_t*       doors(int g)       { return &data[20 + g * 210]; }

    const uint8_t& nbVies(int g)      const { return data[10 + g * 210]; }
    const uint8_t& lastWorld(int g)   const { return data[11 + g * 210]; }
    const uint8_t* doors(int g)       const { return &data[20 + g * 210]; }
};

File Locations

See Save System for per-platform paths. Summary:

PlatformPath
Linux~/.local/share/galaxy-eggbert/gamedata.dat
Windows%APPDATA%\galaxy-eggbert\gamedata.dat
WebEmscripten IDBFS (persisted in IndexedDB)

Usage in GalaxyEggbertGame

// On startup
gameData_.load(savePath);

// When a gamer slot is selected
int slot = gameData_.selectedGamer();
lives_ = gameData_.nbVies(slot);
currentWorld_ = gameData_.lastWorld(slot);

// On world completion
gameData_.doors(slot)[doorIndex] = 1;
gameData_.lastWorld(slot) = currentWorld_;
gameData_.save(savePath);