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
Printable View
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
One of the easiest and most efficient ways is to use a byte array.
Hey, Meg can you show some sample code on how to use the byte array?
Thanks
Sure,
Loading the MapCode:'********************************
'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
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.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
You can assign values to your characters like this.
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).Code:MyChar = 10 'Where ever 10 is on the Map is where "you" are
MyEnemy = 20 '20 is your enemy
'etc.
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
Thanks Meg :))