Step 2: Initializing Our Variables When the Game Starts

Goal:


We want to start with code that will make sure our variables all get reset properly whenever we restart the game.

After the variables are reset then we can start the game.

Steps:

  1. Select the Backdrop.
  2. From Events, place a When flag clicked block.
  3. From Variables, place 2 set blocks.
  4. Set the first variable  to “Blaster Shots:”  and its value to 10.
  5. Set the second variable to “Score” and its value to 0.
  6. From Events, create a broadcast message called “GameStart!

Code:



Click to replay