Repository navigation
Save File System
The game stores each run in a numbered local save slot. Save data includes player progress, checkpoint information, inventory, upgrades, selected weapon and play time.
| File | Purpose |
|---|---|
save_slot_<n>.json |
Serialized game save data |
save_slot_<n>_preview.png |
Preview screenshot shown by the load screen |
GameSaveData stores:
- Save version
- Total play time
- Dungeon completion times
- Current checkpoint
- Resume position
- Player gold
- Inventory
- Charms
- Weapon upgrades
- Selected weapon
When the player presses Exit, MainGameExitDisplay displays three options:
- Save and exit
- Delete save and exit
- Cancel
The game returns to the main menu. During MainGameScreen.dispose(), the current run is captured and saved.
The save process captures the game state with GameSaveMapper, writes it with FileLoader.save(...), and creates a preview image.
This option deletes the current save and preview:
public void deleteSaveAndExit() {
saveOnDispose = false;
runSaved = true;
FileLoader.deleteSaveSlot(saveSlot);
game.setScreen(ScreenType.MAIN_MENU);
}
saveOnDispose prevents the normal disposal process from recreating the deleted save.
The dialog closes and the player continues playing.
LoadGameScreen loads the selected slot with:
GameSaveData save = FileLoader.load(slot);A valid save restores the player's statistics, inventory, charms, weapon upgrades, selected weapon, checkpoint, resume position and play time.
Empty slots start a new run. Unreadable saves can be deleted from the load screen.
| Class | Responsibility |
|---|---|
| GameSaveData | Stores save data |
| GameSaveMapper | Converts game state to and from save data |
| FileLoader | Reads, writes and deletes save files |
| LoadGameScreen | Displays save slots and loads saves |
| MainGameScreen | Saves the current run during disposal |
| MainGameExitDisplay | Displays save and delete exit choices |