Skip to content

Serialization Design

PaulAlger05 edited this page Apr 9, 2022 · 27 revisions

The file format we will use for saving the state of the game and all it's components will be a binary file.
Each object will have it's own serialize/deserialize method to read/write data from/to a binary file.
The binary file will be saved with the following format/order:

currentLevel
 totalEnemies
 screens
   entities
 currentScreen
 currentRow
 currentCol
...and so on

Where each variable corresponds to the variables of the object:

Ex.

  • currentLevel = The world's currentLevel variable (int)
    • totalEnemies = the currentLevel's totalEnemies variable (int)
    • screens = the list of screens the level has (Screen[][])

A small snippet from an example binary file would be the following:
//SaveGame.dat

1
 7
 screen1
   {entity1 , entity2, ... }
 2
 3
 4

Save/load file implementations

Clone this wiki locally