Tiled Map colison

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

Recommended Posts

I make something like in this article http://www.gamedev.net/reference/articles/article1256.asp , to display the map. When i make this, how do i test collsion?

Share on other sites
For a simple 2d tiled environment, axis-aligned bounding boxes (rectangles in 2d) are a good choice. It's fairly easy to implement collision detection and response that seems natural. Another option would be to surround your character or whatever with a circle (easy) or a capsule (a bit harder, but might fit better), and make the tile obstacles AABBs. This can actually be even easier to code than the AABB version.

Also, just to be clear, collision detection doesn't really have anything to do with OpenGL per se, even though the article you refer to uses OpenGL.

Share on other sites
I post in OpenGL forum because the OGL cordinate system.
I have maked 2D tile based games with good colision, but in Allegro, where I test the position by x(0 to 640) and y(0 to 480).
In OGL, is diferent, -1 to 1, and iam confused with the collision

Share on other sites
Quote:
 I post in OpenGL forum because the OGL cordinate system. I have maked 2D tile based games with good colision, but in Allegro, where I test the position by x(0 to 640) and y(0 to 480).In OGL, is diferent, -1 to 1, and iam confused with the collision
I didn't read all of the article you referred to, so I don't know how it sets up the coordinate range. But you can make it whatever you want. You can set things up so that that the screen runs from -1 to +1 horizontally, or -320 to +320, or 0 to 640, or whatever. You can accomplish this through perspecive projection, or (I recommend this) orthographic projection.

If +y goes down in Allegro, you'll have to adjust for that 'cause in OpenGL +y goes up by default. In any case, it sounds like you want an x range of 0 to 640 and a y range of 0 to 480. This can easily be done using an orthographic projection matrix, optionally in combination with the modelview matrix.

Share on other sites
Here is the easiest way to do 2D collisions, use a 2d array that matches the tilemap and mark the map with a symbol "?" whatever you want to denote this is not allowed to be passed through. Fast, and easy no need for AABB or anything like that. HTH

Share on other sites
Quote:
 Here is the easiest way to do 2D collisions, use a 2d array that matches the tilemap and mark the map with a symbol "?" whatever you want to denote this is not allowed to be passed through. Fast, and easy no need for AABB or anything like that.
That will only really work if your character moves in tile-sized steps. Otherwise, you'll have to figure out which tiles the character rect is overlapping and respond accordingly, at which point you might as well use AABBs. Plus, AABBs aren't that hard to work with, especially in 2d.

Share on other sites
I cant program with OGL. I cant uderstand this thing well.
I will try some things, Thanks for all

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• Forum Statistics

• Total Topics
633768
• Total Posts
3013741
×