Step 1: Initial Setup

Goal:


Just like with our game manager our balloon will also need a little bit of initial setup. However, before we do that let’s go over how our variables are going to work for this project.

In the last part, our variable GameOver is either set to 0 or 1. We use the value 1 to say that the game is over, and the value 0 to say that the game is still going on.

Our other variable balloonPopped is either set to 0 or 1. We use the value 1 to say that the balloon has been popped, and the value 0 to say the balloon is not popped yet.

Our game will start with balloonPopped set to 1. We want to trick the game into thinking that the balloon has popped already so that it needs to make a new balloon at the start of the game.

It is a bit confusing, but once you see the code in action you’ll be able to get a better grasp of how this is all working. Anyway, on to the code!

Steps:

  1. Select the “balloon01” sprite. This is where all of the code for this lesson will be.
  2. From Events place a when green Flag clicked.
  3. From Variables place a set to block.
  4. Set the variable to “balloonPopped” and the number value to 1.

Code: