The Daily Click ::. Forums ::. Klik Coding Help ::. How do i do savegames in TGF
 

Post Reply  Post Oekaki 
 

Posted By Message

OscarS



Registered
  10/08/2005
Points
  6
11th August, 2005 at 05:53:21 -

ive been using this program for years and im not bad at it (apart from being a little crappy at doing graphics , but one thing ive never got my head round is how to do savegames, how would i be able to do a savegame system where with a 'start' and 'continue' button on the main title screen, where start will start a new game, and continue will load at the point (or even just the level) that i last used a 'save' function that i could build into my game

thanks

 
n/a

mushi-games



Registered
  17/02/2005
Points
  136
11th August, 2005 at 06:15:24 -

Try searching the articles and the forums, this is a VERY common question...

http://create-games.com/article.asp?id=188

 

He did harken unto her, "hark hark," harkened he.

http://www.freepgs.com/mushi/

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
11th August, 2005 at 08:16:14 -

Look into Ini object or arrays.

 
.

hishnak



Registered
  18/04/2004
Points
  994
11th August, 2005 at 10:23:52 -

I just sat down for an hour and figured them ini's out. Here's another topic somebody posted if it's any help.

http://www.create-games.com/forum_post.asp?id=128728

 
I'm feeling a bit wella

OscarS



Registered
  10/08/2005
Points
  6
11th August, 2005 at 10:24:57 -

alright thanks, whats the difference in inis and arrays just out of interest in terms of what they can do

 
n/a

hishnak



Registered
  18/04/2004
Points
  994
11th August, 2005 at 14:07:18 -

Oh wait, I typed something here then posted it but I realized it was wrong so I just edited it and put this in its place


Image Edited by the Author.

 
I'm feeling a bit wella

OscarS



Registered
  10/08/2005
Points
  6
11th August, 2005 at 21:19:38 -

i got some datastore2 object that works pretty well

 
n/a

Deleted User
11th August, 2005 at 22:36:20 -

I donno either sorry i need someone to teach me in front of me



 

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
12th August, 2005 at 11:17:16 -

The key to it all is understanding that there isn't a 'save/load game' action in TGF. It's not quite that simple.

You see, TGF/MMF doesn't know what you want to save. It's not got any brains, it has no idea what you're using it to create, it just does what you tell it.

So we need to tell TGF what to save and where to save it, AND how to load it back again.

What we use INI Object for is saving the information onto the hard disk in a file. There are lots of extensions that can do this, and they all have their own little pros and cons - array object, associative array object, datastore, Binary Object, Edit Object, List Object, ComboList Object, you name it. But for now we'll just use INI, lol.

Let's suppose we're doing a simple little platformer. We've got 12 big levels, but each has three save points - one right at the start, one in the middle, and one just before the boss of that level.

The player has a lives counter, a health counter, an ammo counter and a magic counter.

So let's think of what to save:
~Level Number (1 to 12)
~Save Point (1 to 3)
~Lives
~Health
~Ammo
~Magic

This is pretty basic. So we'll make it so when the player stands on a save point and presses 'S' it saves the INI file:

This tells TGF where to save everything.
We may as well tell it this at the start so we don't have to bother later.
The appdrive/dir stuff just makes sure it saves it in the same place as
the .exe file of your game.

Start Of Level
-INI Object: Set file to appdrive$+appdir$+"saves.ini"

When the player presses 's', we tell TGF to save the values in
the INI file. Note that it hasn't saved the player's save point yet.
We'll do that after this

Player Presses "S"
--INI Object: Set "Level" to 'level'
--INI Object: Set "Lives" to 'lives'
--INI Object: Set "Health" to 'value("health counter")'
--INI Object: Set "Ammo" to 'value("ammo counter")'
--INI Object: Set "Magic" to 'value("magic counter")'

These three events just check which save point the player
is using.

Player Presses "S"
+Player is overlapping 'Savepoint 1'
--INI Object: Set "Save Point" to '1'

Player Presses "S"
+Player is overlapping 'Savepoint 2'
--INI Object: Set "Save Point" to '2'

Player Presses "S"
+Player is overlapping 'Savepoint 3'
--INI Object: Set "Save Point" to '3'


Do you see how that works? It's just putting numbers inside INI Object and naming them. INI Object then saves them onto the hard disk.

Now we need to make it so when the player presses 'L', it loads that INI file again.

When the player presses 'L', it sets Global Value A to 1 and
loads the level number that we saved. The reason we used the global
value is so when the level starts, it can activate the events for
loading the level. You'll see how this works in a second.

Player Presses "L"
--Set Global Value A to '1'
--Jump to Level 'ItemValue( "Ini", "Level" )'

Here's the command to load all the values (except the save point).
Start Of Level
+Global Value A = 1
--Set Number of Lives to 'ItemValue( "Ini", "Lives" )'
--Set value of 'Health' counter to 'ItemValue( "Ini", "Health" )'
--Set value of 'ammo' counter to 'ItemValue( "Ini", "Ammo" )'
--Set value of 'magic' counter to 'ItemValue( "Ini", "Magic" )'

These three events are to put the player in the right
position for the save point he was in last time.

Start Of Level
+Global Value A = 1
+'ItemValue( "Ini", "Save Point" )' == 1
--Set player position to (position of save point 1)

Start Of Level
+Global Value A = 1
+'ItemValue( "Ini", "Save Point" )' == 2
--Set player position to (position of save point 2)

Start Of Level
+Global Value A = 1
+'ItemValue( "Ini", "Save Point" )' == 3
--Set player position to (position of save point 3)
That's it!

So long as these events are in every level, it'll work.

Any questions, just ask

Image Edited by the Author.

 
191 / 9999 * 7 + 191 * 7
   

Post Reply



 



Advertisement

Worth A Click