Continuing from where we left off in the previous chapter, we will look at collision detection and keeping track of the score in the game in this chapter. Apart from just coding collision detection, we will also look at the different types of collision mechanics in games, be it circular, box, per-pixel, or Box2D collision. Bear in mind that what we will be going through are just few ways of collision detection. A whole book can be dedicated to the topic. What is important for any developer is that they make sure the collision is detected without taxing the CPU too much.
In this chapter, we will cover the following topics:
Theory of collision detection
Circular collision detection
Box collision detection
Per pixel collision detection
Box2D collision detection
Coding collision detection
Keeping track of the score and the game over condition
Storing high score