-2

Imagine that I have a game and I quit the game in the middle of it and then I enter in the game again and I have 2 options, option 1 is to create a new game and option 2 is to reload the state of where I were. My question is, how can I make that?

1 Answers1

2

If you want to reload the status of the old game, you have to save the information of the old game to a file and load it from the file the next time you play.

Storing:

import json

with open('file.txt','w') as f:
    f.write(json.dumps(  myData  ))

Loading:

import json

with open("file.txt", "r") as f:
  myData = json.load(f)