Boat Race
CHALLENGE
MORE LEVELS!
Can you create additional backdrops, and allow the
player to choose between levels?
What will your new level look like? Sketch it out below
and label the finish and any obstacles.
Here’s some when space key pressed
code you next backdrop
can add to
D raw a backdrop idea… your Stage
to switch
between
levels:
101
Boat Race P ROJERCaTceC:OCMomPLpETED! lete
BOAT RACE FULL CODE LISTING Boat www.codeclub.org
BOAT
Steered using the mouse pointer,
the boat must be guided safely
around the course.
when clicked
switch costume to normal This prevents glitching GATE
go to x: -190 y: -150 when the boat gets near
forever This continually spinning gate
the mouse pointer provides a tricky obstacle.
if distance to mouse-pointer > 5 then
point towards mouse-pointer when clicked
move 1 steps forever 1 degrees
if touching color ? then turn
switch costume to hit If the boat STAGE
say Nooooo! for 1 secs touches a brown
switch costume to normal object, it switches This code uses a variable to
go to x: -190 y: -150 to its ‘hit’ costume manage the on‑screen timer.
to show a crash
if touching color ? then When the boat touches when clicked
say Yeah! for 1 secs the yellow island, all
stop all scripts are stopped
if touching color ? then set time to 0
move 3 steps forever
wait 0.1 secs
change time by 0.1
102
OBonaTtaRragceet
Now You Could Make…
You’ll find lots more cool projects at rpf.io/ccprojects, including…
ARCHERY BEAT THE GOALIE
Create an archery game, Create a football game in
in which you have to which you have to score
shoot arrows as close to as many goals as you can
the bull’s-eye as you can. in 30 seconds.
rpf.io/archery rpf.io/beat-the-goalie
ADA’S POETRY GENERATOR Wcaondtessonmipepheatsn?dy
Learn how to create Turn the page to find
randomly generated some useful scripts…
poems! You will be
using variables and
selecting random
items from lists
in this poetic
programming project.
rpf.io/ada-poetry
103
Useful Code
Useful Code
This chapter lists some useful code
that you can use in your projects
Cchoedceksonuipt ptheetss!e
Try using them in your
own projects!
This reference guide
contains useful Scratch
scripts that you can
incorporate into your own
projects. Whatever you
create, have fun coding!
104
Useful Code
DESCRIPTION CODE
Playing a sound when this sprite clicked
play sound pop
Spinning sprite
when clicked
forever 1 degrees
turn
Animating when clicked
sprite costumes
forever
next costume
wait 0.1 secs
Bouncing sprite when clicked
forever
move 1 steps
if on edge, bounce
105
Useful Code CODE
DESCRIPTION when clicked
Drawing a square clear
Keeping score pen down
repeat 4
move 50 steps
turn 90 degrees
pen up
when this sprite clicked
change score by 1
when clicked
set score to 0
Timer counting down
when clicked
set time to 10
forever
wait 1 secs
change time by -1
106
Useful Code
DESCRIPTION CODE
Timer counting up
when clicked
set time to 0
forever
wait 0.1 secs
change time by 0.1
Asking a question when this sprite clicked
and responding to ask Are you ok? and wait
the answer
if answer = yes then
say That's great! for 2 secs
else
say Oh no! for 2 secs
Storing the answer set name to answer
to a question in say join Hello name for 2 secs
a variable
Joining text together
107
Useful Code CODE
DESCRIPTION when this sprite clicked
repeat 4
Jumping sprite
change y by 20
wait 0.1 secs
change y by -20
wait 0.1 secs
Following the mouse
when clicked
forever
go to mouse-pointer
Glide to random set x coord to pick random -240 to 240
stage co-ordinates set y coord to pick random -180 to 180
glide 1 secs to x: x coord y: y coord
Movement towards when clicked
the mouse
forever
point towards mouse-pointer
move 1 steps
108
Useful Code
DESCRIPTION CODE
Movement using when left arrow key pressed
the keyboard point in direction -90
move 2 steps
or…
when clicked
forever pressed? then
if key left arrow
point in direction -90
move 2 steps
if key right arrow pressed? then
point in direction 90
move 2 steps
Check to see if when clicked
a sprite has hit
another sprite
forever
if touching other sprite ? then
say Ouch! for 2 secs
109
SPOT THE DIFFERENCE SPeuczrzlete AMensswaegress
LOST IN SPACEPuzzle Answers ENTER THE CRYPT
B EOJ EAE CAT E SPSR 1101 GHOST
RB Y E URPOAS R SOC T 2 WE R EWO L F
A B S AMPOMT L TAO R T 3 D EMON
PECRBA I ESENRELU 4 M U MM Y
TAGNML O T C AA P D I N 5 TROL L
AV S TMONK E Y T P I T E 6 DEV I L
OMOOUM I J R R E UO S U 7 BUNY I P
ALOTPNEGKUCEROT
NN E BU L AUAC L K E NR
XOX E T LAUTR I OTEM
GAR KAVONR E PU S U R
Y R E XRO E T EMS TAR E
RAYP E E XAUT E KCOR
TCA E T E CKUUSCKP E
TY R YMS SGR L OO ENE
ASTEROID MERCURY PLANET
COMET METEOR ROCKET
ECLIPSE MONKEY SATURN
GALAXY MOON STAR
JUPITER NEBULA SUPERNOVA
Code Club
Book of Scratch
Volume 1
Learn to code using Scratch,
the block-based programming
language. In each chapter you’ll find
instructions to build cool games,
animations, and interactive stories.
Your friendly robot guide will aid
you step-by‑step through each
project and give you handy tips
along the way.
Code Club is a global network of free
coding clubs where young people aged
9-13 build and share their ideas with
code. There are currently more than
12 000 clubs in over 150 countries.
codeclub.org