Public Group

# Tilemap Algorithm

This topic is 5149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Befor I get started I am using BlitzMax. Ok I have this to draw my map...
For Tiley = 0 To 7680 Step 16
For Tilex=0 To 10240 Step 16
DrawImage(Tiles,Tilex,Tiley,0)
Next
Next
Now that code is succesful to drawing the map, with the first tile on my tile sheet. Now, how to I get it to draw a map from an array? Screen is 640x480 which is 40x30 = 1200 tiles
For i = 0 to 1200 step 1
map=0
Next
I am just building from the ground up, not reading from the file yet, just taking small bites. When I put that in my program and run it, the program just crashes. Doesn't do anything. How do I set each object in map[] to 0? My Second problem is getting my map loop to loop through the map[]...
For Tiley = 0 To 7680 Step 16
For Tilex=0 To 10240 Step 16
For i = 0 to 1200 Step 1
DrawImage(Tiles,Tilex,Tiley,map)
Next
Next
Next
Again, my program crashes befor it does anything. What am I doing wrong?

##### Share on other sites
0 to 1200 is 1201 elements.

I think you want 0 to 1200 - 1.

(My VB is a little rusty but it could very well terminate at 1199 already)

##### Share on other sites
Hmm... so you're supposed to set 0 to an array map[]

Am I right? I'm just not that sure what you want to happen here.

##### Share on other sites
Oh. I think it should be like this

temp = 0;

For Tiley = 0 To 7680 Step 16
For Tilex=0 To 10240 Step 16
DrawImage(Tiles,Tilex,Tiley,map[temp])
++temp;
Next
Next

I'm not that much of a VB programmer but I think you get it.

##### Share on other sites
Well unless you want to put it into a multidimensional array

// map[][]

For Tiley = 0 To 7680 Step 16
For Tilex=0 To 10240 Step 16
DrawImage(Tiles,Tilex,Tiley,map[Tiley/16][Tilex/16])
Next
Next

Hehe... I aint no expert

##### Share on other sites
For not I want map[] to be enpty, jsut so I can get the loops done, and add file reading later.

Basicly, I want to know how to loop through an array and add 1200 values.

EDIT: And when I put that code romainechester the incrementer...that won't work becuase it'll go for 7680+10240, thats waaay to much.

EDIT:EDIT: I got it working perfectly! Thanks!

[Edited by - Mr_Fhqwhgads on September 15, 2005 1:21:41 AM]

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 23
• 11
• 25