Jump to content
  • Advertisement
Sign in to follow this  
four_star00

Tile Map

This topic is 4651 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

I am making a 2d tile map using C# in the .Net platform. My question is my map shows the tiles but us going diagonal Any Help also any info on the relationship between the array and the coordinates and size of the image would help too. byte[,] myPic = new byte[102, 101]; for (int y = 0; y < 102; y++) { for (int x = 0; x < 101; x++) { myPic[x, y] = 0; Graphics dc = this.CreateGraphics(); this.Show(); Image myImage = Image.FromFile(@"c:\\Stone.bmp"); dc.DrawImage(myImage, x+=20, y+=4, 20, 20); } } [Edited by - four_star00 on September 24, 2005 5:45:36 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by four_star00
My question is my map shows the tiles but us going diagonal


Can you show a screenshot or something to illustrate your point?

Share this post


Link to post
Share on other sites
I can describe it


using the numbers in the above code,

when I rum my form


my map goes diagonal down

I have noticed by playing around with the numbers


the tiles overlap or spread apart and go diagonal

Share this post


Link to post
Share on other sites
 dc.DrawImage(myImage, x+=20, y+=4, 20, 20)

This would appear to be the problem. Correct me if I'm wrong, but wouldn't you want x + 20, y + 4 instead ? What you're doing here is incrementing the variables themselves, instead of using the values and adding to them to create a new number.

Share this post


Link to post
Share on other sites
I made the corrections and it fixed the diagnal problem but the tiles are overlapping each other instead of each tile being seen fully

Any pointers

Share this post


Link to post
Share on other sites
You'll want to change
dc.DrawImage(myImage, x+=20, y+=4, 20, 20)
to be
dc.DrawImage(myImage, x * 20, y * 20, 20, 20)


(I'm assuming 20, 20 is the size of the image)

This will make it so the loop supplies the x and y coordinates of the tile and then places them in the correct position on the screen for those coordinates rather than just moving across 1 each time like with the addition.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!