In this codelab, you'll learn how to create a scrolling background.

What you'll learn

Open the starter project and click Remix.

First, we are going to create the scrolling background to give the appearance of the bird moving.


The starting positions of each colored cave have been programmed for you.


Look at the code for each cave sprite and understand how the changing the distance traveled variable changes the cave location on screen.
If you have questions, ask a mentor.

Steps

  1. Use the distance traveled variable in code to move the background across the screen.
  2. Reset the background's position at the start of each game.
  3. Add an event block to start the story by clicking the green flag.

Next, we are going to control the parrot's motion.

Steps

  1. Program the parrot to go move up when the space bar is pressed.
  2. Have the parrot go up by 5 when the space bar is pressed and go down by 5 otherwise.
  3. Change the parrot's costume when it goes up and down to make the flying look more realistic.
       

Now, we are going to add winning and losing conditions.

Steps

  1. Use the finish line in the final cave background and an if statement to add the winning condition.
  2. Have the player lose when the parrot touches the cave walls.
  3. Program the game to reset when the player wins or loses.
If you finish early, implement one or more of the following features for a bonus checkoff.