Saving and loading the game<

Return to C++ coding using Panda3D

Saving and loading the game<

Postby samusam » Mon May 07, 2012 3:31 am

Hi,
I would like to know the steps and methods for saving and loading the game.
tnks
Samuele
samusam
 
Posts: 57
Joined: Sat Aug 20, 2011 11:11 am

Postby teedee » Mon May 07, 2012 4:28 am

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.
teedee
 
Posts: 861
Joined: Tue May 12, 2009 11:33 pm
Location: Kepler-22b

Postby samusam » Sat May 12, 2012 10:43 am

but in panda3d not exsisting an interface for selection file?
samusam
 
Posts: 57
Joined: Sat Aug 20, 2011 11:11 am

Postby plaristote » Mon May 14, 2012 11:43 am

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.
Potato.
plaristote
 
Posts: 114
Joined: Sat May 12, 2012 2:02 pm


Return to C++ coding using Panda3D

Who is online

Users browsing this forum: No registered users and 0 guests