PDA

Click to See Complete Forum and Search --> : Map Editors


Spie
Jan 11th, 2001, 08:47 PM
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, 03:10 PM
One of the easiest and most efficient ways is to use a byte array.

Chris
Jan 14th, 2001, 10:11 AM
Hey, Meg can you show some sample code on how to use the byte array?

Thanks

Jan 14th, 2001, 02:18 PM
Sure,

'********************************
'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

'********************
'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.

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).

Spie
Jan 14th, 2001, 03:29 PM
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

Chris
Jan 14th, 2001, 08:05 PM
Thanks Meg :))