Just curious what to do from here. So I am done with my tile editor program and currently have it set up so that my background (which is one large image) is mapped in XML to 32x32 tiles (again, a mapping, nothing is really split into tiles).

So when I have my character (this is a platformer rpg) comes across a tile which I have labeled as obstacle or something, they stop. This is nice and all except for some ugly space in between my character and tile where the edge of my rock is. I can't do pixel detection because it will never be sound.

For example, if my character's pinky ends up in the cell marked as an obstacle and for some reason, there is some black along an edge from a castle from the previous cell, this is a hit even though the player didn't actually touch any part of the rock but rather a part of the pinky hit that black edge.

The only thing I had which makes things seem to nicely lineup is to map it to a 16x16 array.

Edit: I will give the example with pic in the morning since site came back up but for now I'll give a better explanation.

My tile editor exports an XML file of my tile mapping...so, if I specified 32x32 tiles over an 800x600 image, my XML file will contain mappings for each 32x32 tile spread across the region. So I could have my XML file with tile 2 having a type of "Obstacle". I then in XNA just read the XML into a list storing each tile and their characteristics.

I then in my program do a collision check for now. In doing this, I create a rectangle around my player. Each time I move, I check for collision by doing this:

  1. Does my rectangle intersect any collisions with a characteristic of obstacle or wall and so on...

  2. If so, return true that a collision occurred.

So let's say that my background image has a blue background, a castle and a rock in the middle. In a tile I marked as being an obstacle, it contains a piece of the black wall of the castle and to the right of this is a piece of that rock along my path. So my character is now running to the right, will have an intersection with this obstacle tile and as a result, have something like 29 pixels between the player and the start of the rock. This collision occurred as the player hit a tile marked as an obstacle.

Using pixel color collision detection won't help either as a piece of my player could be hitting that black edge of the castle I talked about and the alpha values are never going to be 0.

I'll give a picture example but I am just detailing it a bit better for now.

  • \$\begingroup\$ It might be a little easier for us to make good suggestions if you post a screenshot of what your problem is. \$\endgroup\$
    – zfedoran
    Oct 23, 2010 at 4:07
  • 1
    \$\begingroup\$ How do you check for collision ? Is it with 2d shape vectors or you use a tile-based algorithm ? \$\endgroup\$ Oct 23, 2010 at 20:24
  • 1
    \$\begingroup\$ Please, post an screenshot. Or at least some ASCII art. \$\endgroup\$
    – egarcia
    Oct 24, 2010 at 0:10

1 Answer 1


As an alternative to using cells, you could map the edges of your obstables with vectors (lines), this does not have to be highly accurate, just an approximation of the obstacle shape.

When you do your collision detection you can check if you characters bounding rect intersects with one of the vectors. You can map the vectors to a cell to limit the number of vectors you check against, so when you enter a cell you check your character against the vectors in the cell.

  • \$\begingroup\$ Hrm, good idea and you gave me a further idea I can use with the tiles. What I could do is stick with my tiles and then maybe for tiles that are associated with an obstacle, I could associate a list of vectors with that tile. For example: 1. Test character bounding box coordinate (depending on direction going) and check if it intersects with any tiles associated with a collision 2. If tile is obstacle, check if vector list is associated with tile. 3. If it has a list, check player coords against vector list to see if collision has occured Thanks \$\endgroup\$
    – Ilya
    Oct 25, 2010 at 2:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .