|
-
Jun 3rd, 2002, 11:59 AM
#1
Thread Starter
Member
Save Game
i need to make a save game type of thing where there is a set save point, what it has to save is:
1.What form the player is on
2.What wepon he has equiped (Im making it so that when the player equips a new wepon, it is put into a label, so i only have to save the label caption)
3.The players level (Same as above)
4.The players health (" " ")
5.The party thats with the player (im not sure how im doing that yet)
i also have to make a system for loading a game (when it loads all it does is load the form, and load the captions in, not sure about the players party.) Can anyone help me with these things?
-
Jun 3rd, 2002, 01:14 PM
#2
New Member
You have to use the Random Access to write into the "save file".
Here's an example:
Open "SAVE.sav" For Random As #1 'opens the file
put #1, 1, VarForm 'Just put the name of the activated form
put #1, 2,lblWeapon
put #1, 3,lblLevel
put #1, 4,lblHealth
'....................
Close #1
Then if you want to use the saved game:
Open "SAVE.sav" For Random As #1
get #1, 1, VarForm
get #1, 2,lblWeapon
get #1, 3,lblLevel
get #1, 4,lblHealth
'....................
Close #1
Easy ! isn't it ?
I just didn't understand the 5. (Sorry)
--------------
PHyReXiAN
--------------
-
Jun 3rd, 2002, 06:25 PM
#3
Addicted Member
Uh, actually, use Binary, not Random.
"1 4m 4 1337 #4xz0r!'
Janus
-
Jun 3rd, 2002, 11:06 PM
#4
Thread Starter
Member
so if i want the user to have a choice of not saving in the same slot, and having like 5 slots to save, would i do the same except say save1.sav?
and how would i save using binary?
-
Jun 3rd, 2002, 11:11 PM
#5
Thread Starter
Member
and 5, have you ever played FF or any other rpg game? if you have then im talking about the fighting group you are in, the new characters that join you, and help you through the game, i have to save that also, guess ill let only 6 members go into the party and then the battle engine can check which thez are and substitute them in. Well thanks for tha help.
-
Jun 4th, 2002, 12:16 AM
#6
Addicted Member
Binary and Random both let you use Get/Put, but Get/Put work better in binary mode.
"1 4m 4 1337 #4xz0r!'
Janus
-
Jun 4th, 2002, 05:08 PM
#7
New Member
If I can make a suggestion:
For this kind of games I prefer the Random Access because level names, weapon names, .... have different length.
If you use Binary Access you have to know the length because binary saves bytes per bytes and not plots per plots.
Does it make sense ?
I hope
PS: my mother language is not english.
Last edited by PHyReXiAN; Jun 4th, 2002 at 05:12 PM.
--------------
PHyReXiAN
--------------
-
Jun 4th, 2002, 06:42 PM
#8
Addicted Member
Phyrexian: Random access is only for UDTs. Using it for other data types can have unpredictable results, and you're told specifically not to do so in the docs.
You SHOULD know the length of your data - you're saving it, so you should know. If the length can change, then save it with the data. Just because Random is easy, doesn't mean you should use it - part of coding is learning how to do things the hard, proper way instead of the easy, incorrect way.
"1 4m 4 1337 #4xz0r!'
Janus
-
Jun 5th, 2002, 09:58 AM
#9
Thread Starter
Member
i tried making a simple program to see excapctily how it works, its just a text box, and two command buttons, one for loading, and one for saving:
VB Code:
Private Sub Load_Click()
Open "SAVE.sav" For Binary As #1
Get #1, 1, txttext
Close #1
End Sub
Private Sub Save_Click()
Open "SAVE.sav" For Binary As #1
Put #1, 1, txttext
Close #1
End Sub
and it doesnt work, i also tried random, but that didnt work either
-
Jun 5th, 2002, 10:00 AM
#10
Thread Starter
Member
whoa, major typo there, its suposed to be excactly.
PS: English int my first language either
-
Jun 5th, 2002, 01:22 PM
#11
New Member
I don't understand
For me this piece of code works perfectly:
Private Sub Command1_Click()
Open "****.sav" For Random As #1
Put 1, 1, Text1.Text
Close #1
End Sub
Private Sub Command2_Click()
Dim str As String
Open "****.sav" For Random As #1
Get 1, 1, str
Close #1
Text1.Text = str
End Sub
And this one too:
Private Sub Command1_Click()
Open "****1.sav" For Binary As #1
Put 1, 1, Text1.Text
Close #1
End Sub
Private Sub Command2_Click()
Const length = 5
Dim str As String * length
Open "****1.sav" For Binary As #1
Get 1, 1, str
Close #1
Text1.Text = str
End Sub
You noticed that you have to specify the length of the string.
In fact choose the type of access you want !
(Is that the conclusion ?)
--------------
PHyReXiAN
--------------
-
Jun 5th, 2002, 01:32 PM
#12
Thread Starter
Member
oh, that works fine, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|