Skip to content

Please update your browser

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

arrow_back Step on the Gas (Part 1 of 2)

Transcript

In this step, I'll show you how to create a variable slider to control the racer’s speed. To code this, click on player 1 and data, then select “make a variable.” A variable is: In this case, it's speed. Name this variable “speed,” and select “for this sprite only.” Scratch has now created variable blocks for the speed variable.

I'll drag the speed value into my "move 10 steps" block.

Now, whatever value this variable has will replace the 10 steps that were in the block before.

Notice that right now, the variable has a value of 0. So when I click the up arrow, my sprite doesn't move.

You will see that there's a checkbox next to this block in the scripting menu.

If I uncheck this box, the variable box disappears on the stage.

If I double click this display two times, the user then has a slider that they can control the value of the speed, Let's try changing the speed. Let's try changing it to 5, and a see what happens.

Whoa! The racer is moving pretty slowly.

Let's try changing this value to 20.

Wow, my racer is moving really fast!

You can do this for the player 2 sprite as well. Just be sure to select the “for this sprite only” check box when you create the variable.

Once you complete this step, you can move on to part 2, where you will use the speed variable to slow the driver when they’re on the grass on concrete.

Choose an Add-On
play_circle_filled
Change Up your Racetrack
Add a button that changes the racetrack backdrop.
arrow_forward
play_circle_filled
Costume Change
Change what the racers look like when a key is pressed.
arrow_forward
play_circle_filled
Step on the Gas (Part 1 of 2)
Change how fast the racers move, then make them slowdown on the grass.
arrow_forward
play_circle_filled
Step on the Gas (Part 2 of 2)
Change how fast the racers move, then make them slowdown on the grass.
arrow_forward
play_circle_filled
Crashing Sounds
Play a crashing sound each time the racers hit each other.
arrow_forward
play_circle_filled
Race Fans
Program a sprite to count down to the start of the race and cheer.
arrow_forward
play_circle_filled
Color Trail
Add a colorful trail effect to the racers.
arrow_forward
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!