In this project, we're going to move the aliens to the right. Moving the aliens is going to look very similiar to how we moved the missile in the previous project -- we'll track time to determine when to move the aliens, we'll define how quickly to move them, we'll move them when the time is right:
Here is our initialization code:
Here is our code to move the aliens when the time is right:
Another thing we're going to want to do in this project is to detect whether the aliens have collided with an existing missile, and if one of them has, remove it from the screen (and from the array). And if we remove an alien, we need to check if that's the last alien (if the array is empty), in which case we drop through the loop and end the game:
Lastly, once we drop through the loop to end the game, we'll want to
test if the alien array is empty (in which case the player wins) or the
array is still populated with one or more aliens (in which case the
player loses):
Full project: