|
-
Oct 7th, 2000, 09:48 AM
#1
Thread Starter
Addicted Member
Does anyone know a way to save a game file for an rpg? Like, where the player is at in the game and their current stats. You know, just like saving yer game in Zelda. I don't want to save anything to a text file cuz then anyone could just change it...
To understand recursion, one must first understand the concept of recursion.
-
Oct 7th, 2000, 10:29 AM
#2
Fanatic Member
Ok, this is a small example. You can use a user defined type. Something like this.
Put this code in the general declarations section of the form:
Code:
'the user defined type
Private Type GameInfo
Xpos As Long
Ypos As Long
Health As Integer
End Type
Private Sub WriteSaveGame()
Dim TheData As GameInfo 'the game info
'set the game info
TheData.Xpos = 193
TheData.Ypos = 764
TheData.Health = 69
'write the game info
Open App.Path & "\savegame.dat" For Binary As #1
Put #1,,TheData
Close #1
End Sub
Private Function ReadSaveGame() As GameInfo
Dim TheData As GameInfo 'temporary var
'read the data
Open App.Path & "\savegame.dat" For Binary As #1
Get #1,,TheData
Close #1
'return the data
ReadSaveGame = TheData
End Function
Now your form has 2 functions, you can use them like this.
To Save:
To Open:
Code:
Dim TheData As GameInfo
'read the file
TheData = ReadSaveGame
'put the data in the debug window
Debug.Print TheData.Xpos
Debug.Print TheData.Ypos
Debug.Print TheData.Health
I hope this helped you.
-
Oct 7th, 2000, 11:36 AM
#3
Thread Starter
Addicted Member
Ok, I think that will do it! Thnx a lot.
To understand recursion, one must first understand the concept of recursion.
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
|