Basic Collision-Detection Demo

The CollisionTest demo, included with the source code for the tutorial, demonstrates the collision detection so far. It's the same demo as the BSPMapTest from the previous chapter, except that it adds collision detection and uses the GridGameObjectManager. In this demo, you are stopped when you run against a wall and you can go up stairs to higher platforms. You are also stopped when you run into an object, such as a robot or a crate. The projectiles you fire destroy the robots, and, just for fun, the projectiles stick to the walls, floors, ceilings, and other objects instead of passing through them. Collision detection in this demo works great, but it needs some serious help.

But, hey, good collision handling is a goal of this chapter, so let's fix those problems! And even though it's not really a collision-handling issue, this will be a good time to implement jumping as well because you can detect when an object is hitting something, even in midair.