Game Development Reference
In-Depth Information
Collision detection
Collision detection is what it sounds like; detecting collisions of objects in your game
world. In two dimensions, it's relatively easy since everything generally has simple
square shaped bounding boxes . A bounding box is an imaginary shape around the
object that we use to detect collisions. You just test if the bounding boxes of two ob-
jects intersect each other, and if so, you know that they have collided. Of course, they
are invisible to the player since we never draw our bounding boxes on the screen.
However, it could be useful to add code to your game that lets you see the bounding
boxes for debugging purposes, and verify that they are working as intended. Another
good idea is to add a developer console to your game like those seen in many first-
person-shooter games such as Half-Life 2 .
In 3D, it gets more complicated. There are various types of bounding boxes that you
can use. The commonly used ones are cubical or spherical bounding boxes. The cu-
bic ones don't necessarily need to be perfect cubes. They can essentially be of any
size, or have a longer width than height, for example. The spherical variety is usu-
ally a perfect sphere around an object but it, could be oblong though if the object
is taller than it is wide. The spherical bounding boxes also behave a bit differently
since you won't have cases where just the corners of two bounding boxes intersect,
since spheres do not have corners like cubes do. You could also use different types
of bounding boxes in 2D, of course.
Search WWH ::




Custom Search