Collision Detection and Object Representation in 2D

Once we have moving objects in our world, we want them to interact as well. One such mode of interaction is simple collision detection. Two objects are said to be colliding when they overlap in some way. We already did a little bit of collision detection in Mr. Nom when we checked whether Mr. Nom bit himself or ate an ink stain.

Collision detection is accompanied by collision response: once we determine that two objects have collided, we need to respond to that collision by adjusting the position and/or movement of our objects in a sensible manner. For example, when Super Mario jumps on a Goomba, the Goomba goes to Goomba heaven and Mario performs another little jump. A more elaborate example is the collision and response of two or more billiard balls. We won't go into this kind of collision response, as it is overkill for our purposes. Our collision responses will usually only consist of changing the state of an object (e.g., letting an object explode or die, collecting a coin and setting the score, etc.). This type of response is game dependent, so we won't talk about it in this section.

So how do we figure out whether two objects have collided? First we need to think about when to check for collisions. If our objects follow some sort of simple physics model, as discussed in the last section, we could check for collisions after we move all our objects for the current frame and time step.

Was this article helpful?

0 0

Post a comment