PDA

Click to See Complete Forum and Search --> : Level, come here!!


nXt
Dec 9th, 2001, 08:25 AM
Ok i am drawing maps using an array of images like so

map(0,1) = 1

so the tile 0,1 is picture 1

is there a way i can declare a load of these in a module or text file and call them from a form. eg. instead of saying on form load draw map(0,1)= 2, map(0,2) =1 etc, could i just have draw.map1

or something

Jotaf98
Dec 9th, 2001, 12:37 PM
You can load it from a text file. The text file would look like this:



wwwwwwww
wwsssssw
wsggtgsw
wsgggsww
wwssswww



You don't need to use numbers, you can for example use "w" for water, "s" for sand, "g" for grass, "t" for a tree, etc :)

Now, to load that into the map array, use this:



Dim X as Long, Y as Long, TempStr as String

Open App.Path & "\Map.txt" For Input As #1

For Y = 0 to 5
Line Input #1, TempStr
For X = 0 to 7
Map(X, Y) = Mid(TempStr, X+1, 1)
Next X
Next Y

Close #1



Now, if you use numbers instead of the letters I used, it will work just fine, but you'll be limited to tiles 0 to 9. All you have to do is make each tile in the map a fixed-lenght string (with a lenght of 1), and you can use all the characters you want :)

nXt
Dec 9th, 2001, 01:29 PM
hmmm, but how does this code know where to look for the tile image?

mlewis
Dec 9th, 2001, 01:46 PM
Same way the code I wrote you does.

Jotaf98
Dec 9th, 2001, 02:38 PM
If you don't have too many tiles, you can use a Select Case... of course the most efficient way would be a binary file, but for that you'd have to create a map editor :)