You are on page 1of 9

Easy Cross the Road Project on Scratch

Today, we're going to learn how to make an easy Cross the Road game on Scratch.
We'll be trying to get a car across to the other si
de of the road, and avoid being caught by angry chickens.

Discover how to make an easy cross the road game on


Scratch

1. Draw our Backdrop


Under ‘choose a backdrop’, we’ll select ‘paint’. We can start by drawing one big green
rectangle over our entire backdrop, then draw a smaller black rectangle for our actual
road. Now we need to give our road lines. Let's give our lines a thickness of ten; once
you draw one, you can just copy and paste for the rest. We want 4 white lines, and 2
yellow ones.

1|Page
2. Pick our Sprites
We'll have 4 chickens in our game (one to run in each lane), and a car to cross the road.

2|Page
3. Customize our Sprites
We have to resize all of the chickens to fit within the lines, make the car smaller, Let's
draw eyebrows on them to indicate this.

Now that we have our game properly set up, it's time to start writing code!

3|Page
4. Make a Chicken Move
Let's start with the Hatchling. We just want it to move side-to-side, by itself, when we
click the green flag. A 'move' block, 'if on edge bounce' block, and a 'forever' loop will
achieve this for us. Let's set its rotation style to 'left-right' as well, or else our Hatchling
will turn upside down when it bounces off an edge.

4|Page
5. Make all the Chickens Move
All of our chickens pretty much do the same thing. We can copy code between sprites
by clicking and dragging the code we want to copy over the picture of the sprite we
want to copy it to. We'll give all of our chickens the same code, except each chicken will
move just a little quicker than the last. The more steps we tell our chickens to move, the
faster they'll go, and the harder our game will be!

5|Page
6. Control the Car with the Arrow Keys
In order to control the car, we can use an 'if-then' block to check and see if an arrow key
is pressed. If it is, we'll tell the car to point in the direction of that arrow key, and move a
few steps. We have to make sure to put our 'if-then' blocks inside a 'forever' loop, so
Scratch knows to always be checking if these keys are pressed. If we want our car
facing the same way no matter where it moves, we can set its rotation style to 'don't
rotate'.

6|Page
7. Lose Condition
Our game should end if one of the chickens catches our car. Let's write in our car to
check and see if it's touching any of the chickens. We can use some 'touching' sensing
blocks and some 'or' operator blocks to check this. If our car is touching a chicken, we'll
stop the car from moving, play some sounds, and stop the game. The 'stop other scripts
in the sprite' block is responsible for stopping the car from moving. 'Scripts' is just a
fancy word for code blocks.

8. Win Condition
Now that we can lose, we must also be able to win! Let's edit our backdrop and draw a
big red line on the other side of our road. In our car sprite, we'll check to see if it's

7|Page
touching the color of that line, and if it is, we know we've safely made it to the other side
of the road. We can relish in our triumph with a positive sound effect, and then stop the
game.

Now our game should be functioning, so this is a good time to add some polish! We're
going to animate our chickens, make our game easier to replay, and add some
background music.

9. Animate Chickens
We can animate any sprite using the 'next costume' block, but only if the sprite has
multiple costumes, and only if those costumes make sense to animate with. This is the
case with our Chick, Hen, and Rooster. We'll have them cycle through their costumes,
and use a 'wait' block to control how fast we do it. We're also going to have our
chickens stop moving if they catch the car; this code will go in all four chickens.

8|Page
10. Move Car to a Start Position
If we lose the game, and try to play again by clicking the green flag, we'll likely lose
immediately, because our car is still in the road. We can tell our car where to move when
we click the green flag using its X and Y position. X and Y tell us where our sprite is in
the project space. If you move your sprite, notice how the X and Y change. We'll move
the car to where we want it to start, check the X and Y position, and tell it to go to that
same position when we click the green flag.

9|Page

You might also like