Chapter 5: Collision Detection
To make our game fun, our little Red Hat Boy (RHB) needs to run, jump, and slide. Fortunately, we just implemented all that, but he also needs to have something to jump on, something to slide under, and something to crash into. To make this game fun, we'll need to add collision detection, which is one of the most fun and most complicated aspects of game design.
Collision detection begins with math, detecting whether or not two shapes intersect, but leads to all kinds of interesting questions. We'll deal with some of those in this chapter, such as, how do we handle transparency in sprites? What do we do to make sure a player lands on a platform from above but crashes into a platform if they're underneath it? What about sprites that have shapes that aren't a simple box? It's going to be a blast!
In this chapter, we will cover the following topics:
- Creating a real scene
- Axis-aligned bounding boxes
- Getting bounding...