Please update your browser
Your browser version is not supported by this site. CS First may not work properly. Learn more.
In this video, you'll program the player
sprite's flight through the caves.
To program the sprite to go up
when the user presses the space bar,
and fall if the user stops pressing the space bar,
use a conditional statement.
Click the player sprite, and drag out
an "If L" statement.
Select "Sensing" and add a space key press block.
If the user presses the space bar,
the parrot should move up, so add a "Change Y" block
in the "then" portion of the block.
This example uses 5 in the "Change Y" block.
If the user is not pressing the space bar,
the sprite should move down, so add
a "Change Y" block to the L's, and change the value
to something negative.
This example uses the value of negative 5.
Now this reads, "If the player presses the space bar,
move up, else, move down."
Remember to test your code often to make sure
everything is working the way you want it.
The sprite moves up when you press the space bar,
and moves down when you let it go.
Next, make the sprite look like it's flying
using switch costume blocks.
This may look different depending on
the sprite that you chose to be your player.
Now it's your turn.
Make the sprite move up and down,
using an "If L" statement, a "Forever Loop",
space key pressed, and "Change Y" blocks.
Add costume changes to make the sprite
look more realistic as it flies up and down.
In the next step, you'll program a
winning and losing condition for your game.