Transcript file

 In this tutorial, we are going to create:
 A race car that the user can control with the arrow keys for
direction and speed.
 A simulated road with a striped line down the center showing
"speed" and "motion" of car.
 Obstacles for the car to avoid
To begin with, we are
going to create the stage
for our race car game.
Select the Stage, click
the Backgrounds tab,
then click the Edit
button.
Draw a racetrack
background similar to
the image as shown to
the right.
Now that we have our
stage, we can begin to
create our race car.
Click the Paint new
sprite button and draw
a racecar from the
perspective of looking
down at the car from
above, similar to the
image to the right.
Our race car will be
controlled using the Up
Arrow, Down Arrow,
Left Arrow, and
Right Arrow keys.
Thus, we need to create
scripts for each key.
To begin with, create
the Up Arrow script as
shown in the image to
the right.
This simply moves the
car up by 10 when the
up arrow is pressed.
Next, create the Down
Arrow script as shown
in the image to the
right.
This script moves the
car down by 10 when
the down arrow is
pressed.
To simulate a real car,
we are going to make
the sprite rotate slightly
whenever the user
presses the left or right
arrow keys
Create the Right
Arrow script as shown
in the image to the
right.
Lastly, create the Left
Arrow script as shown
in the image to the
right.
Test all of your arrow
keys to ensure your race
car is working as
intended.
Next we are going to
keep track of the
racecar’s speed.
Create a new variable
(for all sprites) called
Speed.
Create the script as
shown in the image to
the right to keep track
of the racecar’s speed.
The next step in this
tutorial is to simulate
movement and speed.
To do this, click the
Paint new sprite
button and draw a
sprite similar to the
image in the right.
We want our striped
line to continually move
downwards.
To do this, create the
script as shown in the
image to the right.
Next, we want the line
to appear at the top of
the screen once it
reaches the bottom of
the screen.
To do this, create the
script as shown in the
image to the right.
You may need to adjust
how long to wait
depending on how you
drew your line sprite.
The final step in this
tutorial is to create
obstacles for our
racecar to avoid.
Create a new sprite and
draw an obstacle.
In this tutorial, we will
use a puddle of oil as an
example.
We want the obstacle to
repeatedly and
randomly appear on the
screen.
To accomplish this,
create the script as
shown to the right.
Lastly, we want our
racecar to spin out of
control if it touches the
oil.
To do this, click your
Car sprite and create
the script as shown to
the right.
 Congratulations! You’ve finished your racecar game.
 Don’t forget to test your game to ensure everything
works properly.
 See the next slide for additional challenges to
complete.
 Add sounds to your game
 Add a score variable that increases by 1 every 3
seconds, but decreases by 5 whenever the car hits the
oil, and/or whenever the car leaves the road and
drives on the grass.
 Add more obstacles
 Be creative!