Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

Choose an Add-On
play_circle_filled
Make Your Own Music
Add a drum beat and background music to your game.
arrow_forward
play_circle_filled
Add Another Cave Section
Design a new cave sprite with black edges and add it to your game.
arrow_forward
play_circle_filled
Make the Game Harder
Make the player press the spacebar over and over to keep the sprite in flight.
arrow_forward
play_circle_filled
Dangerous Cave Walls
Make the player sprite explode when it touches the walls of the cave.
arrow_forward
play_circle_filled
Add Another Level
Create additional game levels that get faster and harder as the player progresses.
arrow_forward
play_circle_filled
Dive!
Make the sprite dive, or move down faster than it falls.
arrow_forward
  • 1. Side Scrolling Games and If-Else Statements
  • 2. Create a Scrolling Backdrop
  • 3. Making the Parrot Rise and Fall
  • 4. Winning and Losing at Cave Surfing
  • 5. Add-Ons
  • 6. Reflection
  • 7. Wrap-up: Cave Surfing Game
  • 8. Wrap-up: Share Your Project
  • 9. Wrap-up: Show Your Project
arrow_backward Back Next arrow_forward
Transcript

Game play is pretty limited in this game, isn’t it? The user can only press the spacebar to move the sprite up. In this add-on, create a button that allows the sprite to dive, or move down faster than it falls. First, you need to program a key that will tell the bird to dive - this example will use the down arrow - and some way to check if the user is pressing that button. If the user is not hitting the spacebar, he or she might be clicking the down arrow. If the user isn’t clicking either, the bird should still move down, just more slowly. This example will remove the “switch costume to parrot b” and “change y by -5” blocks from the else section of this if-else statement, keeping them to the side to use later.

Then, you will add an "if-else" into the "else"where you just removed the code.

Then, add the "key down arrow pressed" block to the inner if-else statement.

If neither the down arrow nor the space bar are pressed, the bird should still move down, so add the “switch costume” and “change y by blocks that you previously removed to the else.

If the down arrow is pressed, however, the bird should move down faster. Tinker with the values to change the speed the sprite falls. This example uses “change y by -10."

This now reads: “If the spacebar key was pressed, change to parrot-b costume and move up 5. Otherwise, if the spacebar key hasn’t been pressed, then check If the down arrow was pressed.

If it was, then switch to costume parrot-a and change y by minus ten. If the down arrow wasn’t pressed, go down more slowly.” Ok. That seems right.

Test the code to see if it works.

Great!

Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!