0
Saving progress
now i'm working on a game with python and it's working just fine .. it just needs a code to save the progress that the gamer made , so the next time he playes he don't have to start from the beginning .. how can i do it ?!
5 Respuestas
+ 2
You know how to read from and write to files in python? If not , just complete the python course here first.
Then say suppose you want to save the following data in file
noOfLives: 3;
playerName: "Yash";
score: 33;
...
You can simply store
"3 yash 33"
in a file using file I/O and later when you load it you know the first value is for noOfLives, 2ndfor name,etc.
This is the most basic way. Good enough for a beginner. if you want advanced methods then there are also modules like 'pickle' to serialize data and store a JSON structured data in a file.
which could look like:
{
noOfLives: 3,
playerName: "Yash",
score: 33,
cells=[2,3,4],
time:50
}
+ 2
The way I would do it, is to create table in some datebase and search how to connect that database with python. You will need to go through SQL course for this.
+ 1
Simplest way is to save your game data to a local file with File I/O functionality.
Later load it back.
You will also need to define a standard format for the game data for saving and loading.
0
can you explain more please
0
sorry but what does ( File I/O ) stand for or mean excactly ?