June 2015
Intermediate to advanced
388 pages
7h 31m
English
We are really close to being able to play our game, albeit with simplified collision detection. First add some methods that handle what happens when certain collisions are detected and then see how we actually use our CD class.
First of all, we need a couple of helper methods to respond, when we detect various types of collisions.
We need a method for when the ship is destroyed and a method for when an asteroid is destroyed. The next two subsections cover this.
The death of a ship can be detected in two places, so it makes sense to add a method to handle the events that follow. In this next method, we reset the ship's location to the center of the map, play a sound, and decrement numLives.
If
Read now
Unlock full access