{% trans 'Watch it here now.' as msg_meta_extra} Dive! - Cave Surfing Game - CS First Skip to content

Please update your browser

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

Transcript

Gameplay is pretty limited in this game, isn't it?

The user can only press the space bar 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 space bar, 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-a and change y by negative five 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 is 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, the bird should move down faster.

Tink with the values to change the speed the sprite falls.

This example uses change y by negative 10.

This now reads, if the space bar key was pressed, change to parrot-b costume and move up five.

Otherwise, if the space bar key hasn't been pressed, then check if the down arrow was pressed.

If it was, then switch the costume to parrot-a, and change y by minus 10.

If the down arrow wasn't pressed, go down more slowly.

Okay, that seems right.

Test the code to see if it works.

Great. Now it's your turn.

Add another if else inside the first if else that checks if the user has pressed the down arrow.

Then, make the bird move down faster when the down arrow is pressed.

Choose an Add-On
Make Your Own Music
Add a drum beat and background music to your game.
Add Another Cave Section
Design a new cave sprite with black edges and add it to your game.
Make the Game Harder
Make the player press the spacebar over and over to keep the sprite in flight.
Dangerous Cave Walls
Make the player sprite explode when it touches the walls of the cave.
Add Another Level
Create additional game levels that get faster and harder as the player progresses.
Dive!
Make the sprite dive, or move down faster than it falls.
arrow_backward Back
Next arrow_forward
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!
Attributions
  • The song “Magic Marker” is © YouTube-- CC-BY-SA 4.0 does not apply.