Implementing a save feature
Moderator: Coders of Rage
Implementing a save feature
How would you go about implementing a save feature in a game? I was thinking about this the other day and can't find anything about it on Google.
I was thinking something like writing keywords to a file depending on the state of the game, then the game would check the words and restore the previous game state.
Is it something like that, or will I have to get involved with a database? Also, are there any specific game programming books or tutorials you guys know of? Not in any specific language, or how to draw and move stuff on the screen. But something that shows you how to implement game saves, split screen configurations, and various other algorithms specific to game programming?
I was thinking something like writing keywords to a file depending on the state of the game, then the game would check the words and restore the previous game state.
Is it something like that, or will I have to get involved with a database? Also, are there any specific game programming books or tutorials you guys know of? Not in any specific language, or how to draw and move stuff on the screen. But something that shows you how to implement game saves, split screen configurations, and various other algorithms specific to game programming?
"Manually managing blocks of memory in C is like juggling bars of soap in a prison shower: It's all fun and games until you forget about one of them."
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Implementing a save feature
I've never actually done this before, but I believe "serialization" would be the keyword you're looking for.
I'm sure someone more experienced can give you a bit more information about how to go about implementing such a thing.
I'm sure someone more experienced can give you a bit more information about how to go about implementing such a thing.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Re: Implementing a save feature
Awesome! Thanks, time to visit my good friend Google :Ddandymcgee wrote:I've never actually done this before, but I believe "serialization" would be the keyword you're looking for.
I'm sure someone more experienced can give you a bit more information about how to go about implementing such a thing.
"Manually managing blocks of memory in C is like juggling bars of soap in a prison shower: It's all fun and games until you forget about one of them."
Re: Implementing a save feature
You might have missed this:
Writing your own Load / Save routines
It's all C, but it should give you a few ideas.
Writing your own Load / Save routines
It's all C, but it should give you a few ideas.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Implementing a save feature
This totally, 100% depends on your engine. It could be as simple as writing and reading a few lines of text to literally dumping class states in binary and slurping them back up.
- trufun202
- Game Developer
- Posts: 1105
- Joined: Sun Sep 21, 2008 12:27 am
- Location: Dallas, TX
- Contact:
Re: Implementing a save feature
Yeah, I'm a fan of serialization myself. You are essentially taking something in memory (your GameState object) and dropping it to disk (binary, xml, etc.). Then, when the game is loaded, you take that file on disk and reinstantiate the object in memory. However, as Falco mentioned, it depends on your engine. Using serialization requires that your game's current state data is wrapped up into a class (or set of classes), which can be quite an overhaul in some cases.
Re: Implementing a save feature
Never tried it in C/++, but in MMF2 I just stored all the data in an array, which was then sent to an .ini or a .txt and then just read that through.
My friend wrote his own super secret code language to do this, here is a save file from his game(.ini)
My friend wrote his own super secret code language to do this, here is a save file from his game(.ini)
Code: Select all
[Kh{h]
{imvylz{wvpu{z=7
{imvylz{ivzzwvpu{z=7
{hmvylz{wvpu{z=7
{hmh{i|{{zwvpu{z=7
{hmh{i|{{zivzzwvpu{z=7
[Sl}lszJvtwsl{l]
{imvylz{=7
{hmvylz{=7
{hmh{i|{{z=7
[Vw{pvuz]
mvylz{kl{hps=:
lmmlj{zkl{hps=8
[Jolh{z]
is|ukly=7
is|uklyvu=7
tph=7
tphvu=7
pumpup{l|s{yh=7
pumpup{l|s{yhvu=7
pumpup{lolhs{o=7
pumpup{lolhs{ovu=7
I'm an altogether bad-natured Cupid.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Implementing a save feature
Yeah, plaintext is never a good idea if you plan on having any sort of respectable scoring system.Pickzell wrote:Never tried it in C/++, but in MMF2 I just stored all the data in an array, which was then sent to an .ini or a .txt and then just read that through.
My friend wrote his own super secret code language to do this, here is a save file from his game(.ini)Code: Select all
[Kh{h] {imvylz{wvpu{z=7 {imvylz{ivzzwvpu{z=7 {hmvylz{wvpu{z=7 {hmh{i|{{zwvpu{z=7 {hmh{i|{{zivzzwvpu{z=7 [Sl}lszJvtwsl{l] {imvylz{=7 {hmvylz{=7 {hmh{i|{{z=7 [Vw{pvuz] mvylz{kl{hps=: lmmlj{zkl{hps=8 [Jolh{z] is|ukly=7 is|uklyvu=7 tph=7 tphvu=7 pumpup{l|s{yh=7 pumpup{l|s{yhvu=7 pumpup{lolhs{o=7 pumpup{lolhs{ovu=7
Even if you make it only slightly harder to edit the save file, it's much more likely people will play your game legitimately the first time through.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- programmerinprogress
- Chaos Rift Devotee
- Posts: 632
- Joined: Wed Oct 29, 2008 7:31 am
- Current Project: some crazy stuff, i'll tell soon :-)
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++!
- Location: The UK
- Contact:
Re: Implementing a save feature
I guess you could do a bitwise not on all of the characters in the file to get around that problem, or at least the score part of the file, or some wacky and confusing language only your program understands, it's all good really
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P