Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / User saves

Author
Message
Donlan
11
Years of Service
User Offline
Joined: 8th Feb 2013
Location:
Posted: 7th Apr 2013 00:41
How do I create an option for the user to save their progress in my game and continue off from where they were?





p.s I'm new to dark basic

thanks for the help
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 7th Apr 2013 21:46
Tell us all about the game; is it a platform game, RPG? What kind of levels, 3D? 2D? Does it need save points, can the player save from any location?

Donlan
11
Years of Service
User Offline
Joined: 8th Feb 2013
Location:
Posted: 8th Apr 2013 00:27
The player doesn't have to save, like a sort of auto save when a certain event happens.



thank you for the reply!
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 8th Apr 2013 01:55 Edited at: 8th Apr 2013 02:02
Hmm dynamic saving; now that's a cool idea.

I was hoping for you to tell me a little more about the game because that would help me to figure out what I would do; but I'll take a wild, wild guess and assume you are making a 3D adventure game...

I do not know how new you are, but if you are not only new to DBP but new to programming in general then I recommend you follow some beginner tutorials and read some books first, otherwise what I state will just sound like alien language.

Do a search on Daniel's video tutorials, check out my tutorial website: www.binarymodular.com.

Getting started

If you want to be taken through the process of creating the game then you can always ask in this thread or in the forum and I am sure you will get additional help.

The things that would help you understand this procedure include the principles of meshes, limbs and objects. CSV (comma seperated values), Matrix1 utilities plugin and optionally XML (search the forum for MadBits XML plugin). If you understand these concepts then you will understand the following procedures.

There are many ways to save games; but two methods that I prefer include the save object method, and an XML method. The principle I adhere to is to make use of as few functions as possible; so your save and load game function can also be used as a save and load level function. There are also methods that make use of arrays and memory, but I prefer these two because they can be interpreted by external tools.

Now there are two things to take care of; Game states and security.

Game State
Think of the game state as the current situation the player is in.
Object Method
Get the locations and positions of all of your objects that need to be saved and add each object as a limb inside of a temporary level object. All the properties (statistics) can be stored in CSV format in each limb name. This object which contains a limb representation of what is going on in the scene is then saved using the Save Object command.

You could simply store the source file of each object in the limb name and simply load and instance these objects into place; without storing any mesh data (polygons). But if for example it was a Worms game, or a game where the shape of the level can change, saving the mesh structure would make sense.

XML method
Exactly the same as above, except instead of storing the properties in limb names, you store the properties in XML and reload them, search through each entry of data and load objects into their positions with their given statistics.

Security
Anyone can alter your save game file if they can find it and read it or interpret it. Make it hard to find, perhaps give it a wierd file name and store it in a file block with a wierd name in a wierd location using the DBP file block commands; additionally if someone finds the file; stop them from interpreting it by using encryption. Encryption would need to be implemented using one of the snippets in the forum search or codebase. You also need to document your security keys and procedures for your own use.

GunnerWolf
11
Years of Service
User Offline
Joined: 21st Apr 2013
Location:
Posted: 22nd Apr 2013 03:35
The way I handle saves in my text rpg is when you start the game it asks for a name, this is the profile name, the game automatically makes a folder in your documents with the name of the game, in there, it makes a folder called "Profiles" and in there, it makes a folder with the name you entered when you started the game, then it creates text files in there for each character, I format it like so:

I then use this to load and save:
Save:

The final save looks like this:

My loading code includes a debug option, if this is set to true then the program will print the contents of the save file before continuing:

I hope this is fairly easy to understand, I'm relatively new to DBPro so my code may be poor or inefficient, but it works fine for me, no noticeable waiting time, this may not be the case for large save files however

Login to post a reply

Server time is: 2024-11-23 15:05:17
Your offset time is: 2024-11-23 15:05:17