Saving and loading the game<


I would like to know the steps and methods for saving and loading the game.


There is no built in load and save functionality. This is because it depends entirely on your game and what specific data needs to be saved. Basically you need to gather all of the information that needs to be remembered, and dump it into a file.

A VERY simple game for example might only need to remember the position of the player and some enemies. So you could write into the first line of the file the position of the player, and any extra lines after that are positions of enemies. When you load this file, you know the position of the player and where to spawn each enemy. Of course as the game gets more complex the format of the save file will also become more complex.

You might find the json module which comes standard with Python useful. It lets you take a structure of data made up of lists and dictionaries and read and write it easily to a file.

Followup: Just noticed this is in the C++ forum, so the last bit of info may or may not be relevant.


but in panda3d not exsisting an interface for selection file?


There is indeed a page in the manual talking about file handling, but unfortunatly it’s not written yet.

Apparently Panda3D has some classes (everything that starts with “Datagram”) to help you with serialization, probably used for the network part : and there’s also DatagramOutputFile and DatagramInputFile.
I haven’t really looked at them yet, but I think it just might be what you’re looking for.