Adding the alien's components
Remember that some of the alien's components are the same as some of the other components we have already coded. For example, all the aliens and their lasers have a StdGraphicsComponent
. In addition, the alien's laser has the same components as the player's laser. The only difference is the specification (that we have already coded) and the need for an AlienLaserSpawner
interface.
As all the specifications are completed, everything is in place, so we can just go ahead and code these remaining classes shown next.
AlienChaseMovementComponent
Create a new class called AlienChaseMovementComponent
, and then add the following member and constructor methods:
class AlienChaseMovementComponent implements MovementComponent {     private Random mShotRandom = new Random();     // Gives this class the ability to tell the game engine     // to spawn a laser    ...