Jump to content
  • Advertisement
Sign in to follow this  
Mr_Fhqwhgads

Tilemap Algorithm

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!