In this chapter we’ll look at detecting collisions between objects. Now that we’re in control of the ship and shooting projectiles, we should think about taking damage and scoring points. These require that we detect collisions between ship and asteroids for damage and between projectiles and asteroids for scoring points.
We’ll use a simple circle-to-circle collision detection, so all our objects must approximate to circles. It’s very simple to calculate: first, you need to calculate the distance between the centers of the two circles. If that distance ...