Introduction

You are going to learn how to create a game in which a helicopter scores points by watering flowers in the city.

Step 1: Helicopter

Let’s code your helicopter to move across the stage.

Activity Checklist

  • Open the ‘Green Your City’ Scratch project. Your club leader will give you a copy of this project, or you can open it online at jumpto.cc/city-resources.

    Here’s how the project should look:

    screenshot
    screenshot
  • Click your stage and then click ‘Backdrops’. You can then choose a different city backdrop for your game. You can even click the ‘Choose backdrop’ button to choose a different backdrop from the Scratch library.

    screenshot
    screenshot
  • Add this code so that your helicopter starts in the top-left of the stage.

    screenshot
    screenshot
  • Add code so that your helicopter moves to the right until it reaches the edge of the stage.

    screenshot
    screenshot
  • Test your helicopter by clicking the green flag. It should move across the top of the stage until it reaches the other side.

    screenshot
    screenshot
  • Once it has reached the edge, your helicopter should go back to the left side of the stage and move down slightly.

    screenshot
    screenshot

    Notice that the blocks you need to use are set x and change y.

  • Finally, you need to repeat this movement until your helicopter is at the bottom of the screen (its y position is less than -90).

    screenshot
    screenshot
  • Test your helicopter again. It should move across and down until it gets to the bottom of the stage.

    You can make testing quicker by speeding up your helicopter.

    screenshot
    screenshot

Save your project

Challenge: Animate your helicopter

You may have noticed that your helicopter has 2 slightly different costumes.

screenshot
screenshot

Can you use this block to animate your helicopter as it moves?

screenshot
screenshot

Save your project

Step 2: Water

Let’s code your helicopter to drop water onto your flowers.

Activity Checklist

  • Add code to your helicopter sprite, to create a new water drops clone whenever the space key is pressed.

    screenshot
    screenshot
  • Add code to your water drops sprite, so that it is hidden when the game starts.

    screenshot
    screenshot
  • You can then add code so that each new clone appears wherever the helicopter is.

    screenshot
    screenshot
  • Test your code by clicking the flag and then pressing the space bar. A water drop clone should appear whenever space bar is pressed.

    screenshot
    screenshot
  • Now you need to make the water drops fall to the ground.

    screenshot
    screenshot
  • Test your water drops again. This time they should fall to the ground.

    screenshot
    screenshot

Save your project

Challenge: Too much water

Have you noticed that lots of water is dropped if you hold down the space bar?

screenshot
screenshot

Can you use either (or both) of these blocks to fix the problem?

screenshot
screenshot

Save your project

Step 3: Flowers

Let’s code your flowers to grow when they are watered.

Activity Checklist

  • Add code to your red flower sprite to move it to the bottom of the stage at the start of the game.

    screenshot
    screenshot
  • Your flower should move upwards whenever it’s touching a water drop.

    screenshot
    screenshot
  • Click the green flag and then test your red flower by dropping some water drops onto it. Does the red flower move upwards when hit?

    Have you noticed that your flower keeps moving up when it’s touching the water?

    screenshot
    screenshot

    Can you add a wait block so that the flower only moves up once each time.

  • Copy your red flower code to your other flower sprites. To do this, just drag the code onto the other sprites.

    screenshot
    screenshot

Save your project

Challenge: Keeping score

Can you add a score variable to your game? Your score should start at 0, and change by 1 whenever a flower is hit by a water drop.

Here are the code blocks you’ll need:

screenshot
screenshot

Save your project

Challenge: Floating flowers

Have you noticed that if you water your flowers enough times that they move too high?

screenshot
screenshot

You only want your flowers to move up the stage if they’re touching the water and their y position is less than -150.

If a flower’s position is higher than -150 then it should move any further.

Here are the code blocks you’ll need:

screenshot
screenshot

Save your project