
-----------------------------------
SNIPERDUDE
Mon May 08, 2006 5:26 pm

SAVE / LOADING games
-----------------------------------
I'm creating a game and I've made it so I can save and return to a given area, but I don't know how to make it so I can save the game so that I can close the applet and return to the saved game.

How do I do this

Any help would be appreciated  . :scatter:

-----------------------------------
pavol
Mon May 08, 2006 5:46 pm


-----------------------------------
if you know how to work with files, then you can just save the value of your variables in it and when you load the game, just open the file and read the values into your variables. if you don't know how to work with files then just ask

-----------------------------------
SNIPERDUDE
Mon May 08, 2006 6:04 pm


-----------------------------------
I tried a tut, but it didn't help much.  How can I save the integers on a txt, would the ints just be considered a string.  I am just confused, so if you can help me out by being specific and posting a code example - that would be great. :?

-----------------------------------
HellblazerX
Mon May 08, 2006 6:27 pm


-----------------------------------
Have you tried this var file : int %Variable for the file
var fileName : string := "file.txt" %File name
var input : int %Variable to store input from the file
open : file , fileName, put
put : file , 5
close : file
open : file, fileName, get
get : file , input
close : file
put input


-----------------------------------
SNIPERDUDE
Mon May 08, 2006 6:37 pm


-----------------------------------


                        /\
what does the 5 mean?

-----------------------------------
HellblazerX
Mon May 08, 2006 7:06 pm


-----------------------------------
With that code, I'm writing the number 5 into the file.  So with the put command, the first variable, file, states which file I'm writing to, and the second part states what I am writing, which in this case is the 5.

-----------------------------------
SNIPERDUDE
Mon May 08, 2006 7:58 pm


-----------------------------------
Seems to make sense, but how do I save several ints?

And how would I get back and read several ints?

-----------------------------------
Bored
Mon May 08, 2006 9:02 pm


-----------------------------------
Well after each put statement it will add a new line tab so when you want to read an integer it would be:
get : file, variable
When putting to a file it's the same as putting to the screen only it's save as a txt and not displayed in the window. Then each line is like a predefined user input so you simply get the information with the get command. It works the same as user input with the put and get commands only it's getting from a file rather then the user and putting to a file rather then the screen.

-----------------------------------
SNIPERDUDE
Tue May 09, 2006 6:46 am


-----------------------------------
Thx, I'll try it out...

I'll b back if I need any more help.
