We’ll make a minor enhancement to Galactic War in this chapter by adding support for an animated explosion. To facilitate this, we’ll have to write some new code to handle the timing and state properties for each sprite. The goal in this chapter is to add a handler for responding to ship-asteroid collisions. When a collision occurs, the game should animate an explosion over the ship, and then put the ship into a temporary invulnerability mode so the player can get the heck out of the way before another collision occurs.
Here are the key topics we’ll cover in this chapter:
Examining possible interactions among the game entities
Adding collision detection between the player’s ship and the asteroids ...