Project 6: Anvil Game

Step 1

Program Setup


In the last project, we learned how to combine loops, conditions and the “setBlocks” function to create a program that made gigantic tunnels for us.

In this project, we are going to go back to the infinite/forever loop to create a game where anvils fall from the sky! The goal of the player is to live as long as they can without getting hit.

First, add the code to your project as shown. Here we see a new import, for the “random” library. We’ll see why we need this in a bit. Can you guess why it will be important? Or what it might do?

We also need to use the “time” library again, for the same reasons as the last program.