This post is a portion of Part 12 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.
- 12.0 – Collision Detection
- 12.1 – Bounding Rectangle Collision Detection
- 12.2 – Distance Based Collision Detection
- 12.3 – Pixel Perfect Collision Detection
In game development, and more specifically programming, there are many pieces that have to fit correctly in an efficient manner. Of these things, efficient collision detection is the Holy Grail. Many games that come out, whether they are 2D or 3D, fighting or shooting, often cause player frustration with improperly handled collision detection. In some games, an obvious hit get’s ignored by the system, while other times complete misses end up killing you. While I am not going to get into the intricacies of 3D collision detection, the concepts are primarily the same. We need to detect when two or more objects are occupying the same “world space”.
Before we get into the different types of collision detection, it is worth noting what will and won’t be covered. First off, this section is on the detection of collision and not the resolution of collision. These videos will only take you so far. What happens when a collision occurs is a very specific question whose answer needs to be tailored to your specific game. Also, in keeping with the theme of this web series, I won’t be getting too far into the complexities of some of the potential algorithms. Even when I cover pixel perfect collision detection, I am still going to keep the conversation more high level. Finally, I am presenting the concepts here. There may be more efficient means of achieving the same thing. This isn’t necessarily a code clinic as much as an intro.
Let’s get to it!