Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Advanced search

1401054 Posts in 67847 Topics- by 61382 Members - Latest Member: lolapaluuza

May 27, 2022, 10:44:54 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Save games in C++
Pages: [1]
Author Topic: Save games in C++  (Read 2658 times)
Level 2

"Swedish meatballs"

View Profile WWW
« on: September 04, 2007, 04:40:16 PM »

Ok, so still learning C++ and fumbling along reasonably with some basic stuff for an RPG engine, and I've decided its time to think about saving game states, except, i cant find much about how best to do that...

Do any of you friendly indy dev sorts have any advice?

I'm not overly concerned with space saving as much as its imperative that i can easily dump the entire state of play somehow (and understand how to restore it relatively easily..)


One day I'll think about doing something to stop procrastinating.
Level 7

Yip yip yip yip yip

View Profile WWW
« Reply #1 on: September 04, 2007, 10:21:52 PM »

This is a pretty big field, really. A surprising amount of difficulty too.

What do you need to save? Just scalar/string data, or do you need to save references?

If your references only can ever go "one way" (i.e. your object graph is a strict tree), then it's easy to just use some hierarchy (I use XML). But you kind of have to plan for this sort of thing from the start.

If you just want to serialize the player, his location, and some other generic stuff (like story flags) you should have no real concern.

But the first order of business is determining what you want to save.

Second: What relationships do these things have to one another? Does each actor need to serialize a reference to its target, or can you rebuild that at game load?

The fewer references you're serializing, in general, the easier your time will be.

When you're loading: What data do I need to have in my hand in order to load this actor? Do I need to have already loaded the texture data for it? If so, does the actor need to know what texture I should use to draw it? How will I refer to that?
« Last Edit: September 04, 2007, 10:25:02 PM by ravuya » Logged

Level 0

View Profile
« Reply #2 on: September 06, 2007, 09:45:19 AM »

Your question is too general to answer easily. There's also no general, best way. As ravuya said, you need to think about what you need to save, and how to represent that data in your file(s). If you want help with that, it would be easier if you provided more details on what you want to save.

You say nothing about your level of experience, but the first step is obviously to learn how to read and write files, so that you can (for example) write the player position as plain text to a file, then read that file, parse the position and set the coordinates in the game.

Versus entry: Battle Mode
Pages: [1]
Jump to:  

Theme orange-lt created by panic