Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with a game...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mike Pastah




PostPosted: Mon Jan 06, 2003 8:33 am   Post subject: Help with a game...

My friend and I have been working hard on a Turing RPG game, and it's a bit clumsy and the commands are scattered around, but it works pretty well... but the game has gotten pretty big, so we want to know how it would be possible to create a save game that can be saved and loaded... any help is good... thanks

Mike
Sponsor
Sponsor
Sponsor
sponsor
Sie_Kensou




PostPosted: Mon Jan 06, 2003 12:04 pm   Post subject: (No subject)

To save/load games it is nessesary that you write your code in such a way that it could easily be loaded and reloaded...

you are making an RPG you say? the variables you use I assume are something like: playerType, life, mana, level, strength, etc, etc. You could save this variables in a text file and then load them next time you play. Of course you must write a proc/function to load it. Also depends if you have always the same start location everytime you load the game or you can actually "freeze" the game when you save and load it exactly where you were when you saved (I really don't recommend this for an RPG, would be a pain in the .... )

if you need the commands to read/write files, this is a small example:

var fn : int
var playerName : string

open : fn, "save.dat", get
get: fn, playerName
close: fn

This will load the first word in the file "save.dat" and use it as the playerName. You can keep retrieving the next data (of course you must know the order in which you saved it)

hit F9 and you'll see a detailed explanation of how to use it if you didn't understand the example above. To write to a file, use:
open : fn, "save.dat", put

I hope it helps
Tony




PostPosted: Mon Jan 06, 2003 1:16 pm   Post subject: (No subject)

Dan has a detailed explanation of reading/writing to a file there -> http://danco.no-ip.com/turing/viewtopic.php?t=5

And as Sie_Kensou was saying, to save/load the game you just need to write down values of variables and then assign those values back to the variables to load the game.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
azndragon




PostPosted: Wed Jan 08, 2003 6:30 pm   Post subject: (No subject)

I myself have run into a problem like this when I was trying to make my RPG save. First of all, use read and write, not put an get, because that's what I used. Despite the fact that the Tutorial uses get and put, and this method uses read and write, the process is almost completely identical, so don't let that confuse you. Juat make sure that there is a way from different save points will bring you do different locations.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: