Game Development Reference
Learning to live with it
The first solution, which is not really a solution at all, is to design your game according to the con-
straints that depPaopK^fa_p imposes on you. Limitations can be an enormous strength (in the same
way that writing poetry according to the rules of a sonnet can be a strength). They can help you focus
and streamline your design—just ask Shakespeare!
If you know that depPaopK^fa_p works best with square or rectangular objects, design your objects
Have a look at the owl and pig characters that you used in this chapter. They're both square shaped,
but you wouldn't know that unless you actually saw a square outline traced around them. They've
been designed so that most of the edges and corners meet the edges of the grid square in which they
were designed. This means that there are very few places in which the shape of the character doesn't
fill the bounding box, so the shapes of the objects almost always overlap when a collision occurs.
However, there are a few spots on both of these objects where a collision will be detected even if the
shapes don't overlap. Figure 7-23 shows an example.
Figure 7-23. The bounding boxes overlap,
even if the shapes don't.
Isn't this the fatal Achilles heel in the whole system? Not if the objects are moving fast enough, and
in most games they will be. The empty gap between the edge of the bounding box and the owl's wing
isn't more than about 5 pixels at its maximum. Remember that the lh]uan object in these examples is
moving at the rate of 5 pixels every 1/30 of a second. That's really fast. It's so fast, and the gap is so
small, that no one playing the game would ever notice that the collision wasn't accurate.
Of course, if the objects were moving slower, you'd have a problem. But the point of this section is
this: design your game so that it's not a problem. Make your objects short and stout, and make them
move reasonably quickly. If you can do that, depPaopK^fa_p will be all you'll ever need.
Have a look some of your favorite 2D games. Isn't it funny that all the characters and objects seem to
be sort of plump and square-ish? You got it, baby! They're dealing with exactly the same constraints
you're dealing with here. Welcome to the video game designer's club!