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

Username:   Password: 
 RegisterRegister   
 Saving, how does it work
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Quakerstate98




PostPosted: Sat Jun 17, 2006 2:58 pm   Post subject: Saving, how does it work

how do you make it so you can save your game.
In the help menu i found GUI.Save but how does it work?
Sponsor
Sponsor
Sponsor
sponsor
Reality Check




PostPosted: Sat Jun 17, 2006 3:06 pm   Post subject: (No subject)

Well, what I'd do is this, whenever they click a save button (or however you'd like to implement save), Then, if they press save, I'd save all the required variable values such as: position of character, health, level, score and if you had a game that gives items or power ups to the character, I'd also save which items they currently hold and then when they click load I'd just load up all those variables. It wouldn't be too hard but I'm sure theres some easier way to do it but I don't know it. What game are you doing?
TheOneTrueGod




PostPosted: Sat Jun 17, 2006 3:16 pm   Post subject: (No subject)

Well, the easiest way to do it would be to not save at all Very Happy

But other than that, what RC said holds true. Additionally, there are some things you will want to do. Before you do any of those, be sure to know about File I/O. Should be some info on that in the [Turing Walkthrough].

Allright, for extra stuff. Try

    (*)Naming the save files something other than ".txt". By doing this, you will deter the not-so-swift-with-computers people from hax0ring the save files.

    (*)Encryption. There are several good ones out there, but my preferred one is using xor. Unfortunately, this limits you to using ints, so it all depends on what you're doing. Either research some commonly used encryption methods, or create your own, so it can't be cracked Very Happy. (In theory)
Quakerstate98




PostPosted: Sat Jun 17, 2006 3:19 pm   Post subject: Save

I'm making a diablo type game, so i would need to save what items you have, money, exp lvl etc, but i don't know teh first thing about saving
TheOneTrueGod




PostPosted: Sat Jun 17, 2006 3:21 pm   Post subject: (No subject)

Aye, so read up on the File Input and Output. Its in the [Turing Walkthrough]. All you do is save the variables to a data file, and load them from it later.
Reality Check




PostPosted: Sat Jun 17, 2006 3:30 pm   Post subject: (No subject)

its simple, I imagine you have variables for your exp, your money, your items (stored in array I'd suggest), and everything else from positioning. When they click save, store all of your variables in a file and load them. When you run it'd output everything you have last. Don't forget to save EVERYTHING. Including things like monster position, their health, your health, and the position they are in the level. After all, when you start your health would be preset at 100 I'd imagine and exp would be at 0. You'd add to exp everytime they kill something. heres an example:

code:

if monster1 killed then
exp += 100
elsif monster2 killed then
exp += 200
end if


Your exp is now at 100 or 200 depending on who you killed. When they hit save you'd store the number in a file and then load them back up. Your character would then start at 200 instead of 0. Of course this is only the exp. Your other variables such as health and level position should be constantly changing. If you don't understand this then I'd suggest you either do an easier game that won't require saving, or simply making your game shorter to make it beatable in one play.
TheOneTrueGod




PostPosted: Sat Jun 17, 2006 3:34 pm   Post subject: (No subject)

If you're making an RPG, I strongly suggest you learn OOP, as it'll make your life SO much easier. You should be loading many things from data files, like monster stats, weapon stats, the level layout, etc... This will make your life a lot easier when, say, you want to create a second area.
Reality Check




PostPosted: Sat Jun 17, 2006 3:42 pm   Post subject: (No subject)

Yea an RPG is pretty hard to pull off. You probably shouldn't be using Turing to do this. You will have many variables like the stats, how you level up, this is going to be a big project. I'd suggest making a file for each monster and loading it when you encounter them. So load up the file thats according to the specific monster and the file should include stats like strength and speed and everything. Maybe you'll know what kind of monsters are in each level so when they start the level, you'd load up the monster stats and apply it to the monster. AI will be an issue as well. For the easier levels maybe you could have them attack less often and the higher levels their stats will not only be higher they will move around more and attack more often. For the attacking you could do do a random integer and for the lower levels make it like 1 to 5 and if the radnom int is a 1 then attack. For a higher level you'd make it 1 to 2 and if its a 1 then it'll attack. So the higher level has a higher chance of attacking. Just ask for help if you get stuck. Forget about the saving now I suggest and do that as an extra if you have time.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sat Jun 17, 2006 11:01 pm   Post subject: (No subject)

TheOneTrueGod wrote:
Encryption. There are several good ones out there, but my preferred one is using xor. Unfortunately, this limits you to using ints, so it all depends on what you're doing.

Luckily, characters are really just integers, and strings are just a bunch of characters, so we're all set! Wink
TheOneTrueGod




PostPosted: Sat Jun 17, 2006 11:34 pm   Post subject: (No subject)

Aye, but I find working with reals in RPGs is quite a bit more fun than sticking with nice even numbers Wink . Theres allways the possibility of doing things like multiplying all of your real numbers by 100 and then typecasting them as an int (via round) before encryping them, and then when decryping, using the "/" operator on em.
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  [ 10 Posts ]
Jump to:   


Style:  
Search: