Let’s say you have game of tic tac toe and you want to save the board state in a file. The board is 3×3 large and let’s say zero equals x, one equals o, two equals empty.
You could save the board by going from left to right, top to bottom row:
220202022 then represents this board:
“`
X
X
X
“`
OK you just made a file format for tic tac toe. Other games do the same but just include more data. Let’s say you defined a specific order of saving for example
1. The version of the save format
1. Dialog options you took
2. Items and their position in the inventory
3. Amount of gold you have
4. Your username
5. Your x, y and z coordinates
5. etc.
Now you just go like before from left to right and save each thing with a value et voilà you persisted state.
Write a loading screen that reads said file in the exact same order and you have your state back.
Latest Answers