Step 3: Creating the Balloon Behavior

Goal:


Now that we’ve coded the ability for a balloon to appear, let’s code how they should behave (otherwise they would just stay in one spot the whole game!).

We will want our balloons to constantly go up (positive y direction) until they either get clicked by the player (which we’ll do next) or if they hit the top of the screen.

After this step we’ll have seen if “ballonPopped” = 1 twice. What does this if statement mean again? If you’re not sure check Step 1 for a quick hint!

Steps:

  1. From Control, place a repeat until block under the if then block from the previous step.
  2. From Operators, place an “=” block inside the repeat until block.
  3. From Variables, place a round “balloonPopped” block on the left side of the “=” block.
  4. On the right side of the “=” block type in the number 1.
  5. From Motion, place a change y by block inside the repeat until block.
  6. Inside the change y by block, type in the number 6.
  7. From Control, place an if then block underneath the change y by block.
  8. From Operators, place a “>” block inside the if then block.
  9. From Motion, place a round y position block on the left side of the “>” block.
  10. On the right side of the “>” block type in the number 180.
  11. From Variables place a set to block inside the if then block.
  12. Set it to the variable “balloonPopped” and the number value to 1.
  13. From Looks, place a hide block underneath the set to block.
  14. From Control, place a wait block underneath the repeat until loop, be sure it says 1 seconds.
  15. From Events, place a broadcast block. Set its message to be “CreateBalloon!”

Code: