SPACE INVADERS 7
In this project, we'll continue animating the aliens.
I/O (Input/Output) RaspberrySTEM Cell
LED Matrix RaspberrySTEM Cell
Accelerometer RaspberrySTEM Cell
Having issues? Check out the Troubleshooting Guide.

In this project, we'll start with our code from the last project (where we moved the aliens to the right), and we'll add moving the aliens back to the left and increasing the speed as they get closer and closer to the bottom of the LED Matrix screen.

To do this, we'll need to create two new variables to track the direction of the aliens (+1 or -1) and the speed of the aliens (a multiple of the default speed we set in the last project).

Here is our initialization code:



And here is the code we will add to our game loop:



Here is what the full project code should look like at this point -- give it a try, and you should now see the aliens going back and forth:



home | prev | next