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.

14 thoughts on “Challenge #7: Why Collisions Do Not Work?

  1. you forgot to turn your monitor on

  2. @Toni: That’s correct. :) I told you it was a memory issue… ;)

    @JR: uh..

  3. 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.

  4. Forgot to actually call the function? :)

  5. Hint: Are you thinking too much about erroneous code rather than the root of the problem?

  6. @soniCron: lol, no :)
    @Jake: nope.

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

  8. He erroneously chose to use a non-managed programming language? ;)

  9. I know the answer. We’ll it was me that made the stoopid mistake :)

  10. Here’s another hint: it was a memory issue (but you need to guess what kind of issue)

  11. absolute vs relative coordinates?

  12. Perhaps the developer forgot that the y-axis points downward on the computer screen? :)