Now that we have the tap controls implemented, it is time to add some enemies that the player can boost to avoid.
This is going to be much easier than when we added our player's spaceship because most of what we need is in place already. All we have to do is code a class to represent our enemy, instantiate as many enemy objects as we need, call their
update methods, and then draw them.
As we will see, the
update method for our enemy will be quite different to that of
PlayerShip. It will need to handle things like simple AI to fly toward the player. It will also need to handle respawning when it leaves the screen.
To begin with, create a new Java class and call it
EnemyShip. Add these member variables inside ...