Challenge #7: Why Collisions Do Not Work?

It’s been some time since the last challenge, so here’s a new challenge. This actually came friend of mine. He asked me:

“Have you ever written a really nice collision routine and spent ages trying to work out why it does not work?”

Can you guess what was the reason why the nice collision routine did not work? The only hint I can give that this same problem occurred to me when I tried getting particles on screen, and I saw nothing on screen.

Juuso Hietalahti


  1. I once encountered a problem with collisions. It was funny because its one of those occasions where since the code does exactly what you wanted, it gives you an anomaly. Basically it was a tiled map game where you see the entities from above ( picture zelda for the snes if you’d like ). Now every entity had a bounding box to collide with the blockade type tiles, in which they also had bounding boxes. So its a basic rectangular BB collision scene. Now, what i used to do is that when an entity wanted to move, i moved its position, and the BB with it, along the tilemap and then checked to see if it collided with the blockade type tiles. If it did, i would then realign the entity with the tilemap, so that it would be touching the blockade, not overlapping it. The code in itself worked nicely. Now here’s the problem. Suppose you have a wall of blockade type tiles, like a whole line of it on the tilemap. Now suppose an entity, that has a rectangular BB is moving downards AND left. What would happen sometimes is that the BB would overlap 2 blockade types in the tilemap. I made the code recognize that and realign itself with the positions of the blockade tiles. So since its moving to the left, it would realign itself with the tilemap it overlapped. Like i said, this was done by moving the entity to back to the right in this case. Since it also overlapped the blockade tile directly below it, it would also realign it to go back up again. Now if you keep this scene going a few times you’ll notice whats goin on. The entity that should scroll along the wall isn’t moving! Took me a while to understand the why of it. I got it solved now, so it’s one of the many other bugs from the past heh.

  2. Failed to use BMax collision layers properly? Or was trying to collide with an empty image! Thus no collision.

Comments are closed.