|
-
Jan 11th, 2001, 09:47 PM
#1
Thread Starter
Lively Member
I am trying to make a map editor for my tile-based RPG. I need to know how to do things like save the map (the right information) and load it.. help is greatly appreciated. 
-Spie
-
Jan 12th, 2001, 04:10 PM
#2
One of the easiest and most efficient ways is to use a byte array.
-
Jan 14th, 2001, 11:11 AM
#3
PowerPoster
Hey, Meg can you show some sample code on how to use the byte array?
Thanks
-
Jan 14th, 2001, 03:18 PM
#4
Sure,
Code:
'********************************
'Creating and saving the Map file
'********************************
Dim Map(5, 5) As Byte
'Create numbers (items, enemies etc.) in the byte array
For X = 0 To 5
For Y = 0 To 5
Map(X, Y) = X * Y 'Assign a number
Next Y
Next X
Open "MyMap.map" For Binary Access Write As #1
Put #1, , Map
Close #1
Loading the Map
Code:
'********************
'Loading the Map File
'********************
Dim Map(5, 5) As Byte
Open "MyMap.map" For Binary Access Read As #1
Get #1, , Map
Close #1
'Loop through and display the number at each coordinate
For X = 0 To 5
For Y = 0 To 5
Debug.Print Map(X, Y)
Next Y
Next X
Make sure in your game, though, that the Map is declared at global or module level because you would be using it throughout your project.
You can assign values to your characters like this.
Code:
MyChar = 10 'Where ever 10 is on the Map is where "you" are
MyEnemy = 20 '20 is your enemy
'etc.
Then you can move the characters up or down by looping through the Map file and when 10 (your character) is found, then change your current position to a 0, and assign the ajacent position to 10 (your character).
-
Jan 14th, 2001, 04:29 PM
#5
Thread Starter
Lively Member
Wow! That was (I think) excatly what I needed.. Do the other things, like the MyChar and MyEnemy save automaticly, or do I have to tell it to save?
Thanks,
Spie
-
Jan 14th, 2001, 09:05 PM
#6
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
|