Step 4: Letting Players Pop the Balloon

Goal:


Our balloon should now know how to fly to the top of the screen, and pop when it reaches the top.

Next up we need to make it pop if the player clicks it.

We will also have it send a “balloonPopped” message to the balloon that we already set up last lesson to add points for us!

Once this step is completed, the game will be complete! Feel free to play it and see how high of a score you can get!

Now that you know how to program one balloon, what would it take to program more than one? How difficult do you think this would be? Can you think of multiple ways to do this?

Be sure all your code is in the “balloon01” sprite!

Steps:

  1. From Events, place a “when this sprite clicked” block.
  2. From Control, place an if then block.
  3. From Operators, place an “=” block inside the if then block.
  4. From Variables, place a round “GameOver” block on the left side of the “=” block.
  5. On the right side of the “=” block type in the number 0.
  6. From Variables place a set to block inside the if then block.
  7. Set the variable to “balloonPopped” and the number value to 1.
  8. From Looks, place a hide block.
  9. From Events, place a broadcast block, and set its message to “BalloonPopped!”
  10. From Control, place a wait block. Be sure it says 1 seconds.
  11. From Events, place a broadcast block, set its message to “CreateBalloon!”

Code: