|
-
Dec 9th, 2001, 09:25 AM
#1
Thread Starter
Member
Level, come here!!
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
-
Dec 9th, 2001, 01:37 PM
#2
Frenzied Member
You can load it from a text file. The text file would look like this:
Code:
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:
VB Code:
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
-
Dec 9th, 2001, 02:29 PM
#3
Thread Starter
Member
hmmm, but how does this code know where to look for the tile image?
-
Dec 9th, 2001, 02:46 PM
#4
Frenzied Member
Same way the code I wrote you does.
-
Dec 9th, 2001, 03:38 PM
#5
Frenzied Member
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
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
|