Jump to content
  • Advertisement
Sign in to follow this  
Jazonxyz

Help in tilemap collisoin.

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

How can I detect collision in a tilebased map? I have drawn up the map in mappy and I can render it perfectly but I dont know how I can detect collision in the map. I simply took all the tiles and drew them on a Image and then rendered the Image. I used an array and took the imformation from the array. Here is an example of the array I used: const int Map[10] = { 10,20,10,10,10...} I am using C++.

Share this post


Link to post
Share on other sites
Advertisement
Basic collision, between a point and a rectangle, is pretty easy. Just check that the point is inside all four sides. Between two reactangles is slightly more complex, but still easy to test.

If either rectangle is entirely inside the other, or if any pair of their edges cross, then they intersect. Just google "rectangle intersection" if you can't figure it out after drawing it and thinking on it a while.

Once you've got two-rectangle intersection test down pat, just look at your map. Each tile is a rectangle of its own.

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!