Copyright by Jonathan S. Harbour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 13. Galactic War: Squashed by Space Rocks

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required