Computer Coding Projects For Kids A Unique Step-By-Step Visual Guide, From Binary Code To Building Games, 2nd Edition PDF
Computer Coding Projects For Kids A Unique Step-By-Step Visual Guide, From Binary Code To Building Games, 2nd Edition PDF
COMPUTER CODING
P
FOR KIDS
rojEctS
COMPUTER CODING
P
FOR KIDS
JON WOODCOCK
FOREWORD BY CAROL VORDERMAN
DK UK
Senior editor Ben Morgan
Project editor Ben Ffrancon Davies
Senior art editor Jacqui Swan
Consultant editor Craig Steele
Jacket design development manager Sophia MTT
Jacket editor Emma Dawson
Jacket designer Surabhi Wadhwa
Producer, pre-production Gillian Reid
Senior producers Meskerem Berhane, Mary Slater
Managing editor Lisa Gillespie
Managing art editor Owen Peyton Jones
Publisher Andrew Macintyre
Associate publishing director Liz Wheeler
Art director Karen Self
Design director Phil Ormerod
Publishing director Jonathan Metcalf
DK INDIA
Senior editor Suefa Lee
Project editor Tina Jindal
Project art editors Sanjay Chauhan, Parul Gambhir
Editor Sonia Yooshing
Art editors Rabia Ahmad, Simar Dhamija, Sonakshi Singh
Jacket designers Priyanka Bansal, Suhita Dharamjit
Jackets editorial coordinator Priyanka Sharma
Managing jackets editor Saloni Singh
DTP designers Jaypal Singh Chauhan, Rakesh Kumar
Senior managing editor Rohan Sinha
Managing art editor Sudakshina Basu
Pre-production manager Balwant Singh
This edition published in 2019
First published in Great Britain in 2016 by
Dorling Kindersley Limited
80 Strand, London WC2R 0RL
Printed in China
A WORLD OF IDEAS:
SEE ALL THERE IS TO KNOW
www.dk.com
CAROL VORDERMAN MA (CANTAB), MBE, is one of Britain’s best-loved TV
presenters and is renowned for her mathematical skills. She has hosted numerous
TV shows on science and technology, from Tomorrow’s World to How 2, and was
co-host of Channel 4’s Countdown for 26 years. A Cambridge University engineering
graduate, she has a passion for communicating science and technology, and has
a keen interest in coding.
12 Creative computers
82 Birthday Card
14 Programming languages
94 Spiralizer
16 How Scratch works
106 Fantastic Flowers
18 Getting Scratch
20 The Scratch interface
22 Types of project
In recent years, interest in coding has exploded. All over the world, schools
are adding coding to their curriculums, code clubs are being launched to
teach beginners, and adults are returning to college to learn coding skills
now considered vital in the workplace. And in homes everywhere, millions
of people are learning how to code just for the fun of it.
Fortunately, there’s never been a better time to learn how to code. In the
past, programmers had to type out every line of code by hand, using obscure
commands and mathematical symbols. A single full stop out of place could
ruin everything. Today, you can build amazingly powerful programs in
minutes by using drag-and-drop coding languages like Scratch™, which is
used in this book.
As learning to code has become easier, more people have discovered the
creative potential of computers, and that’s where this book comes in. Computer
Coding Projects for Kids is all about using code for creative purposes – to make
art, music, animation, and special effects. With a little bit of imagination
you can produce dazzling results, from glittering firework displays to
kaleidoscope-like masterpieces that swirl and beat in time to music.
If you’re completely new to coding, don’t worry – the first two chapters
will walk you through the basics and teach you everything you need to
know to use Scratch. The later chapters then build on your skills, showing
you how to create interactive artworks, life-like simulations, mind-bending
optical illusions, and some great games.
Learning something new can sometimes feel like hard work, but I believe
you learn faster when you’re having fun. This book is based on that idea,
so we’ve tried to make it as much fun as possible. We hope you enjoy
building the projects in this book as much as we enjoyed making them.
CAROL VORDERMAN
On your marks...
get set... CODE!
What is
coding?
12 W H AT I S C O D I N G ?
Creative computers
Computers are everywhere and are used in all sorts of
creative ways. But to really join in the fun, you need to
take control of your computer and learn how to program it.
Programming puts a world of possibilities at your fingertips.
▷ A simple recipe
Imagine you want a friend to bake a cake, but your
Easy peasy!
friend has no idea how to cook. You can’t simply give
them an instruction like “make a cake” – they won’t
know where to start. Instead, you need to write a
recipe, with simple steps like “break an egg”, “add
the sugar”, and so on. Programming a computer Recipe
is a bit like writing a recipe.
Recipe
Ingredients
2. Seven colours
◁ Step by step Instructions
Now imagine you want to 1. Clear the screen to create a white background.
program a computer to create
2. Repeat the following ten times:
a painting like the one shown
here, with coloured circles a) Pick a random place on the screen.
overlapping each other at b) Pick one of the circles randomly.
random. You have to turn the c) Pick one of the colours randomly.
job of painting the picture into
d) Draw a see-through copy of the circle
a kind of recipe, with steps the at that place in that colour.
computer can follow. It might
look something like this:
C R E AT I V E C O M P U T E R S 13
▷ Computer language
Although you can understand the recipe when clicked
for a painting or a cake, a computer can’t.
forever
You need to translate the instructions into
move 10 steps
a special language that the computer can
understand – a programming language.
The one used in this book is called Scratch.
Worlds of imagination
There isn’t a single creative field in the world that hasn’t been touched
by computers. In this book, you’ll get to make lots of great projects that
will fire your imagination and make you think and code creatively.
Building games programs is just as much fun as Special effects and dramatic scenery in films
playing them, especially when you make all the rules. are often created in graphics programs.
14 W H AT I S C O D I N G ?
Programming languages
To tell a computer what to do, you need to speak the right
kind of language: a programming language. There are lots
to choose from, ranging from easy ones for beginners, like
the one in this book, to complex languages that take years
to master. A set of instructions written in any programming
language is called a program.
☞✜✂★❂✮✓
Popular languages
There are more than 500 different
Hello!
programming languages, but most programs
are written in just a handful of these. The
most popular languages use English words,
but lines of code look very different from
English sentences. Here’s how to get a
computer to say “Hello!” on screen in
just a few of today’s languages.
▷C
The C programming language #include <stdio.h>
is often used for code that main(){ printf(“Hello!”); } Hello!
runs directly on a computer’s
hardware, such as the Windows
operating system. C is good for
building software that needs to
run fast and has been used
to program space probes.
#include <iostream>
▷ C++ int main()
This complicated language is used {
to build large, commercial programs std::cout << “Hello!” << std::endl;
such as word processors, web }
browsers, and operating systems.
C++ is based on C, but with extra
features that make it better for
big projects.
PROGRAMMING LANGUAGES 15
class HelloApp {
when clicked public static void main(String[] args) {
say Hello! System.out.println(“Hello!”);
}
}
△ Scratch
Beginners often start with simple programming
languages such as Scratch. Instead of typing out △ Java
code, you build scripts with ready-made coding blocks. Java code is designed to work on all types
of devices, from mobile phones and laptops
to games consoles and supercomputers.
Minecraft is written in Java.
print(“Hello!”)
LINGO
Code words
Algorithm A set of instructions that
are followed to perform a particular
task. Computer programs are based
on algorithms.
△ Python Bug A mistake in a program. They are
Python is a very popular, all-purpose language. called bugs because the first computers
The lines of code are shorter and simpler than had problems when insects got stuck in
in other languages, making it easier to learn. their circuits.
Python is a great language to learn after Scratch.
Code Computer instructions written in
a programming language are often called
code. Coding is programming.
alert(‘Hello!’);
△ JavaScript
Programmers use JavaScript to create
interactive features that run on websites,
such as advertisements and games.
16 W H AT I S C O D I N G ?
Sprites
Sprites are the objects shown on the screen. Scratch comes with
a huge selection of sprites – such as elephants, bananas, and
balloons – but you can also draw your own. Sprites can perform all
sorts of actions, like moving, changing colour, and spinning round.
I’m a sprite!
wait 1 seconds
wait 1 seconds
ONLINE OFFLINE
Visit the Scratch website at http:// Visit the Scratch website at http://
scratch.mit.edu and click on “Join scratch.mit.edu/download and follow
Scratch” to create an account with the instructions to download and install
a username and password. You’ll Scratch on your computer.
need an email address too.
Online Scratch runs in your web browser, Scratch will appear as an icon on
so just go to the Scratch website and your desktop, just like any other
click on “Create” at the top of the screen. installed program. Double-click on
The Scratch interface will open. the Scratch cat icon to get going.
You don’t have to worry about saving You’ll need to save your project by
your work as the online version of clicking on the File menu and selecting
Scratch saves projects automatically. “Save to your computer”. Scratch will
ask you where to save your work –
check with the computer’s owner.
Motion Events
Looks Control
when clicked
Sound Sensing hide
x: -126
y: 96
Pen Operators repeat 300
move 10 steps
turn 15 degrees
when I receive Bang ▾
go to Rocket ▾
point towards ▾
point in direction pick random –180 to 180
go to x: 0 y: 0 show
Stage hide
1 backdrop Rocket Stars
New backdrop:
Backpack
SCRATCH File Edit Tutorials Untitled Share See Project Page scratch-cat
Motion
Motion
move 10 steps
when clicked
Looks
turn 15 degrees forever
repeat 3
Sound turn 15 degrees
switch costume to ballerina-a
glide 1 secs to x: 0 y: 0
repeat 2
Sprite Sprite1 x 20 y 80
Stage than in the older versions. Key changes
include the addition of new sprites, a
My Blocks
Show Size 100 Direction 90
Backdrops
1
better sound editor, and the “Extensions”
Dinasaor1 Dinosaur2 Dinosaur3 Ballerina
section, where you can find many new
Backpack programming blocks.
EXPERT TIPS
Mouse-pointers
Scratch needs some accurate something with your computer
mouse-work, which is easier to mouse. If your mouse only has
do with a computer mouse than one button, you can hold down
a touchpad. In this book, you’ll the shift or control key on your
often be instructed to right-click keyboard as you click.
20 W H AT I S C O D I N G ?
The Scratch
Use the Sounds
Select the tab to add music
Code tab to Change Menu and sound effects
build the code. language options to sprites.
interface
This is Scratch mission control. SCRATCH File Edit Tutorials Untitled
glide 1 secs to x: 0 y: 0
Operators
point in direction 90
Variables
SPRITES
LIST
B A C K PA C K S TA G E L I S T Backpack
when clicked
forever
repeat 3
repeat 2
Backdrops
Click here
to zoom in. 1
Dinosaur1 Dinosaur2 Dinosaur3 Ballerina
Types of project
This book has a wide range of fun Scratch projects. Don’t
worry if you haven’t used Scratch before or you’re not an
expert – the “Getting started” chapter is there to help
you. Here’s a handy guide to the projects in this book. 60
60 G E T T I N G S TA R T E D
G E T T I N G S TA R T E D
ASK GOBO
ASK GOBO
61
61
48 G E T T I N G S TA R T E D Ask
Ask Gobo
Gobo ANIMAL RACE 49 Click this icon to
Click this
escape theicon
full-to
Do you have a tricky decision to make The green flag The red button
Animal Race
escapemode.
the full-
Do youThehave a tricky decision to make The green
starts flag
the project. The red
stops thebutton
project. screen
or wantevery
tobat
predict the future? Let Gobo
flaps its wings starts the project. stops the project. screen mode.
Click the green flag or want to predict the future? Let Gobo
time you press
to start the project. help youthein
“z”this
key. fortune-telling project.
help you in this fortune-telling project.
Have you ever wondered which is Here you’ll learn about random numbers, ◁ Ask a question!
Here you’ll learn about random numbers, ◁ Ask a question!
faster – a dog or a bat? Now you variables, and how computer programs Gobo works best if you ask
variables, and how computer programs itGobo works best if youorask
can find out when you play this make choices. to make predictions
it to makefor
predictions
make choices. decisions you. Don’torask
fun fast-finger, button-pressing, ◁ Fastest finger first decisions
factual for you.as
questions Don’t ask
it’ll often
two-player animal race game. Go! factual
get questions
the answer as it’ll often
wrong!
As soon as the cat starts
get the answer wrong!
the race, the dog and the
I can answer your
How
How itit works
works
bat start racing towards
the balloons. The faster the
I can answer
yes-or-no your
questions.
yes-or-no questions.
Gobo invites you to ask a question and players press their keys,
Gobo invites you to ask a question and the faster their sprites race.
then answers with either “Yes” or “No”.
How it works then answers with either “Yes” or “No”.
You can ask anything you like, from “Am
You can ask anything you like, from “Am Gobo uses speech
The aim of this two-player game is simply I going to be a billionaire?” to “Should I Gobo uses
bubbles speech
to interact
I going to be a billionaire?” to “Should I bubbles to interact
to race across the screen and reach the play a computer game instead of doing Ask your question with you when you
play a computer game instead of doing Ask your
pressquestion
withthe
run you when you
project.
balloons before the other player. Fast my homework?” Gobo pauses to look then space. run the project.
my homework?” Gobo pauses to look then press space.
finger action is all you need to win. like it’s thinking, but its answers are
like it’s thinking, but its answers are
The faster you tap the keyboard’s “z” actually pure chance.
actually pure chance.
or “m” key, the faster your sprite moves
from left to right.
Balloons mark
◁ Gobo the finish area.
◁ Gobo
Friendly Gobo is the only Get ready to see
◁ Sending messages Get ready to see
Friendly Gobo is the It
only into the future!
This project shows you how sprite in this project. has into the future!
spritecostumes
three in this project. It has
that you
to use Scratch’s message
three
can usecostumes that bring
later to help you
feature to make one sprite
pass information to other itcan use later to help bring
to life.
it to life. Catch me
sprites, such as when the
if you can!
cat sprite tells the dog
and bat to start racing.
◁ Take a chance
◁ Take a chance
Just as the roll of the dice
Just as random
creates the roll of the dice
numbers,
◁ Variables
creates can
Scratch random numbers,
generate
The cat’s code stores Scratch numbers
can generate
information in something random to
randomthenumbers
programto
3 programmers call a variable. make
make
in the program
unpredictable
react
react
ways.
In this project, you’ll use
Cat Art (p.26) Dino Dance Party (p.34) Animal Race (p.48) Ask Gobo (p.60)
in unpredictable ways.
a variable to store the
numbers for the cat’s count The dog runs for the finish – one
at the start of the race. The cross and arrow stride every time you press the
Count mark the start line. “m” key.
△ Getting started
Work your way through these easy projects to learn how to
use Scratch. Each project introduces important new ideas, so
don’t skip any if you’re a beginner. By the end of the chapter,
you’ll have mastered the basics of Scratch.
94 AR
A RT
T SP
S P II R
RAAL
L II Z
ZEER
R 95 Funny Faces (p.70)
83
Spiralizer B I R T H D AY C A R D
◁ Art
is the perfect tool
birthday card. This Angle
Angle 10
10
Y!
ing sharks, but you
BIRTHDA
Clones
△ Clones
e project to make How it works △
Clones are
Clones are working
working copies
copies
△ Gliding
Speed around 2
ir own unique card. This simple
This simple project
project has
has only
only one
one sprite:
sprite: aa Speed 2 of sprites.
of sprites. When
When aa clone
clone isis
134
134
134
134 GGA
GAM
A AMM
M EES
SESS
Y ON YOUR BIRTHDAY!
Each line
Each line is
is drawn
Scratch’s Pen
Scratch’s
drawn using
using
Pen extension,
extension, Scratch pen
△ Scratch
△ pen
Window
Window
WindowCleaner Cleaner
Cleaner
Slime
Slime
Slime tim
tim
Slimetim
ti
have dreamed of. Make a
which lets
lets any
any sprite
sprite draw.
draw. Every sprite
sprite can
can draw
draw aa
which Every
trail behind
trail behind it it wherever
wherever To
To
To make
make
make
To make som
som
somso
it goes
it goes –– just
just add
add the
the
draw
draw
draw
draw some
some
some
some ss
green “pen
green
to its
“pen down”
its code.
down” block
code. By
block
By adding
adding
Messy
Messy
Messy windows?
windows?
Messywindows?
windows? You’d
You’d
You’d better
better
You’dbetter get
get
betterget up
getup up and
and
upand clean
clean
andclean them!
them!
cleanthem!
them! and
and you’ll
you’ll bb
be
to
the Pen
Pen extension
extension you
you This
This frantic
frantic game
game counts
counts how
how many
many splats
splats you
you can
can and
andyou’ll be
you’ll
△ Keeping time the
This
Thisfrantic
franticgame
gamecounts
countshow howmany
manysplatssplatsyouyoucan
can
birthday card, spin spectacular
Like Animal Race, this get extra
get extra blocks
blocks added
added
Each cloned
cloned ball
ball flies
flies in
in project uses messages sent to the
to the blocks
blocks palette
palette to
to clean
clean
clean off
off
cleanoff your
your
offyour computer
computer
yourcomputer screen
screen
computerscreen inin
screenin aaaminute.
ina minute.
minute.
minute. You
You
You
You
111 right-clic
Each
change the the pen’s
pen’s colour,
colour, Startaa ane
Start
Start n
ne
aa straight
straight line
line from
from the
the from one sprite to another change Start a
centre to
centre to the
the edge.
edge.
to control the timing of
shade, and
shade, and thickness.
thickness. can
can
can wipe
wipe
canwipe away
away
wipeaway the
the
awaythe splats
splats
thesplats either
either
splatseither by
eitherbyby using
using
byusing aaacomputer
usinga computer
computer
computer right-cli
right-clic
right-c
andselec
and sele
code blocks. The singing
mouse
mouse
mouse
mouseor or
or by
by
orby waving
waving
bywaving your
your
wavingyour hand
hand
yourhand inin
handin front
front
infront of
of
frontof aaawebcam.
ofa webcam.
webcam.
webcam. and
and selec
se
with flowers.
nen
ne
The
The
TheThe game
game
game
game starts
starts
starts
starts by
byby
by cloning
cloning
cloning
cloningaaasplat
asplat
splat sprite
sprite
sprite
splat sprite and
and
and and scattering
scattering
scattering
scattering
▽
▽ Splatsprite
Splat
▽Splat
▽
sprite
sprite
Splat sprite
clones
clones with
with different
different costumes
costumes randomly
randomly across
across the
the stage.
stage. Thisgame
This
This gamehas
game hasone
has onesprite
one sprite
sprite
clones
clones with
with different
different costumes
costumes randomly
randomly across
across the
the stage.
stage. This game
withseveral
with
has one
severalcostumes,
several costumes,
costumes,
sprite
When
When
When
When motion
motion
motion
motion isisis
is detected
detected
detected
detected by
by
by the
the
the
by the webcam,
webcam,
webcam,
webcam, Scratch
Scratch
Scratch
Scratch uses
uses
usesuses with
with several costumes,
122
122
122
122 G
GAAGMA
GMAEEM
MSSEE SS UTTN
TT U NUNN
UNNEEN
NLLEEO
LL FFO
ODFF O
ODOO
DOOMO
OM 123
123
123
123 whichyou’ll
which
which you’llpaint
you’ll
which you’ll
paintyourself.
paint yourself.
yourself.
paint yourself.
O D M M
its
its
itsits“ghost”
“ghost”
“ghost”
“ghost” effect
effect
effect
effect tototo
to make
make
make
make the
the
the
the splats
splats
splats
splats fade.
fade.
fade. IfIfyou
If
fade. Ifyou
youyou wave
wave
wave
wave your
your
youryour Bycloning
By cloningthe
cloning thesprite
the spriteyou
sprite you
you
ByBy cloning the sprite you
TunnelofofDoom
Tunnel Doom Dodare
Do you
Do you
you dare
Dodare
you dare
to enter
to enter the the
hand
hand
hand
hand
game
game
enough,
enough,
enough,
enough,
is
is toto remove
remove
they
they
theythey eventually
eventually
eventually
as
as
eventually
many
many
disappear.
disappear.
disappear.
disappear.
splats
splats as
as you
you
The
The
The
can
can
The
in
aim
aim
aim
in
aimofofof
of
one
one
thethe
thethe
minute.
minute.
cancover
can
can coverthe
cover
can cover
splats
splats of
of
thescreen
the screenwith
screen
the screen
messy
messy gunk.
gunk.
with
with
with
Scratch is
to enter
“Tunnel
to enter
“Tunnel
the the
of Doom”?
of Doom”? game
game is is
totoremove
remove asas
many
many splats asas
splats you can
you canininone
one minute.
minute. splats
splatsof of
messy
messy gunk.
gunk.
Scratch
Scratch
Scratch is is the
is the
thethe ideal
ideal
ideal
ideal playground
playground
playground
playground forfor
for for making
making
making
makingand
andand
and Will Will
youryour
Will Will
timetime
youryour
timetime
“Tunnel
“Tunnel
of Doom”?
of Doom”?
perfecting
perfecting
perfecting
perfecting games.
games.
games.
games. ToTo
To win
To win
win at at
at
win at this
this
thisthis game,
game,
game,
game,you
youyou
you need
need
need
need
The The cat starts
cat starts
The The
cat starts
here.here.
cat starts
here.here.
TimeTime
TimeTime
in seconds
in seconds
in seconds
in seconds
be fastest?
be the
be the
the fastest?
be fastest?
the fastest?
aa steady
aa steady
steady
steady hand
hand
hand
hand and
andand
and nerves
nerves
nerves
nerves of of
of of steel.
steel.
steel.
steel. Take
Take
Take thethe
the
Take catcat
cat
the cat
allall
all thethe
the way way through
through thethe
the Tunnel
Tunnel of of
of Doom,
Doom, butbut
333 Select
all thewaywaythrough
through the
Tunnel
Tunnel of
Doom,
Doom,but but Selectthe
Select th
the
don’t touch Select
don’t
don’t
don’ttouch
touch
touch thethe
thethe walls!
walls!
walls! ForFor
For
walls! anan
an
For an extra
extra
extra
extra challenge,
challenge,
challenge,
challenge, anddraw
and draw
draw
andand dra
▷ Games
trytry
try to to
to
try beat
to beat
beat thethe
the
beat the best
best
best
best time.
time.
time.
time. largespla
large sp
Time
Time
Time
Time
201201
201201 large spla
large s
Score 4242
Score
Score 42 42
Score painting
painting
painting
Best
Best timetime 245245 paintin
How it
BestBest
timetime 245245 Reach home
to to willget
will getsh
get
it works
Reach home
How
How
Howit
it works
works
works Reach
Reach
home
win win
win win
home
to to
the game.
the game.
the game.
the game.
Countdown
Countdown 8 8
Countdown 8 8
Countdown will
will gesh
UseUse
Use your
Use your
youryour mouse
mouse
mouse
mouse to to
to move
to move
move movethethe
the catcat
cat
the all all
all
cat thethe
the
all the way
way way through
through
waythrough
through
190
190 MUSIC AND SOUND
MUSIC AND SOUND
D R U M TA S T I C
D R U M TA S T I C
191
191
Drumtastic Dancing
Dancing cat
cat
To make the project more fun, the cat will dance and A,B,C,D...
A,B,C,D...
Virtual Snow (p.144) Firework
This
This project
Display
project turns
turns your
(p.154)
your computer
computer keyboard
keyboard into
into aa drum
drum
Fractal Trees (p.162) Snowflake Simulator (p.172)
To make the project more fun, the cat will dance and
shout out each letter in a speech bubble as the drums
shout out each letter in a speech bubble as the drums
This project turns your computer keyboard into a drum play. Follow the steps below to create a custom block
play. Follow the steps below to create a custom block
machine.
machine. Type
Type inin anything
anything you
you want
want and
and Scratch
Scratch turns
turns that plays the drums and animates the cat.
the that plays the drums and animates the cat.
the letters
letters into
into repeating
repeating drum
drum sounds
sounds using
using up
up to
to
18
18 different instruments, from cymbals and bongos
different instruments, from cymbals and bongos
to
to pounding
pounding bass
bass drums.
11 Start a new project and keep the cat
Start a new project and keep the cat
33 Now create a custom block for the cat sprite. Choose
Now create a custom block for the cat sprite. Choose
△ Simulations drums. sprite. Set the background to a solid
sprite. Set the background to a solid
colour by clicking the paint symbol
colour by clicking the paint symbol
in the backdrops menu, picking a
“My Blocks” in the blocks palette and make a new block
“My Blocks” in the blocks palette and make a new block
called “play a drum”. This will trigger code that plays
called “play a drum”. This will trigger code that plays
a drum and makes the cat say the drum’s letter at the
in the backdrops menu, picking a a drum and makes the cat say the drum’s letter at the
Give a computer the correct information and it can mimic,
cool colour, and using the fill tool same time. To keep things simple, the first version of
cool colour, and using the fill tool same time. To keep things simple, the first version of
▽ Scratch drumkit to create a coloured backdrop. Make the code will play the same drum sound every time.
How
How it it works
works
▽ Scratch drumkit
The code turns every letter
to create a coloured backdrop. Make
sure you’ve clicked the “Convert to
sure you’ve clicked the “Convert to
the code will play the same drum sound every time.
Words
The words The drums light up Words
Words Click “OK” to
Sprites and Sounds (p.182) Drumtastic (p.190) The typed
you words
you typed
The
as drums
the light
sounds up
play.
as the sounds play.
Cymbals
Cymbals
Choose this option.
Choose this option.
Click
complete the“OK” to
block.
complete the block.
◁ Mindbenders
Making images move in clever ways can fool
the eye into seeing amazing patterns and
optical illusions. Try these mindbending,
spinning-pattern projects.
EXPERT TIPS
Perfect projects
Every project in this book is do, go back a few steps and check
broken down into easy steps – the instructions again carefully.
read each step carefully and you’ll If you still have problems, ask
sail through them all. The projects an adult to check with you. Once
tend to get more complicated you’ve got a project working,
later in the book. If you find a don’t be afraid to change the
project isn’t doing what it should code and try out your own ideas.
Getting
started
26 G E T T I N G S TA R T E D
How it works
This simple project lets you use a
computer mouse to paint multicoloured
cat art. Wherever you drag the mouse, a
rainbow trail of cats is left behind. Later
on you’ll see how to add other effects.
◁ Artistic cat
This project lets you go wild
with your imagination. You
can experiment with a variety
of colours, sizes, and effects
for the cat, and in the end
your project will look like
a piece of modern art.
Mouse control
The first step is to make the cat sprite move wherever
the mouse-pointer moves. You need to build a set of Follow me.
SCRATCH File Edit Tutorials Untitled Share See Project Page scratch-cat
Motion
Motion
move 10 steps
Looks
turn 15 degrees
point in direction 90
Variables
point towards mouse-pointer Stage
Sprite Sprite1 x 0 y 0
My Blocks
Backdrops
1
Code is Sprite1
built here.
repeat 10
Sound
Events
Variables
My Blocks
goes. You can stop the chase with the red stop
button. Congratulations on your first working
Scratch code!
30 G E T T I N G S TA R T E D
Multicoloured cats
Scratch is packed full of ways to make
art. The simple code changes here will
send your cat straight to the art gallery.
go to mouse-pointer
12 You’ll find that the stage soon fills up with cats, but
don’t worry, as you can add code to wipe it clean at when space key pressed
the press of a button. Choose Pen in the blocks
palette and look for the “erase all” block. Drag it into erase all
the code area but keep it separate from the first
code. Then click on Events and add a yellow “when
space key pressed” block. Run the project and see This header block starts the
what happens when you press the space-bar. code when the chosen key is
pressed on the keyboard.
EXPERT TIPS
Full screen
To see projects at their Click here to
best, you can simply click see your project
fill the screen.
the full-screen button just
above the stage to hide
the code and just show the
results. There’s a similar
button to shrink the stage
and reveal the code again
from full-screen mode.
▽ Smooth changes
Don’t be afraid to experiment with the numbers and settings
in Scratch commands. You don’t have to change the cat’s
when clicked
colour effect by 25 each time. The lower the number, the
more slowly the colour will change, like in this rainbow. forever
go to mouse-pointer
stamp
EXPERT TIPS
Scratch's ghost effect Code runs from The “forever” block makes
makes sprites transparent. top to bottom. the program return to the
start of the loop.
when clicked
forever
when left arrow key pressed
change color effect by 25
change ghost effect by –1
34 G E T T I N G S TA R T E D
How it works
Each sprite has one or more blocks of
code that program its dance moves.
Some simply turn from side to side, but
others glide across the dance floor or
perform more varied moves. You can
add as many dancers as you like.
◁ Dinosaur
After you’ve created a dancing
dinosaur, you can duplicate
this sprite to make a group of
dinosaurs dancing in rhythm.
◁ Ballerina
To add a touch of class, the
ballerina will perform a more
complicated dance routine.
DINO DANCE PARTY 35
By switching between
different poses, the
sprites appear to dance.
Let’s party!
36 G E T T I N G S TA R T E D
Dancing dinosaur
Scratch has lots of ready-made sprites for your project in the
sprites library. Many of the sprites have several “costumes”,
each showing the sprite in a different pose. If you make
a sprite switch costumes quickly, it looks like it’s moving.
Control go to x: 0 y: 0
Dinosaur4
Click here to
duplicate load a new sprite.
delete
Choose a Sprite
export
DINO DANCE PARTY 37
5 Look at the dinosaur on the stage and press the space-bar. Every time
you press it, the dinosaur will change its pose. It’s still the Dinosaur4
Each pose is a different
costume belonging to
sprite, but the way it looks keeps changing. Each different pose is called the dinosaur sprite.
a costume and can be used to make a sprite appear to do different things.
dinosaur4-b
233 x 158
dinosaur4-c
130 x 179
Dance steps
By using loops you can make the dinosaur change
its costume repeatedly, making it appear to move.
Changing pictures quickly to give the illusion of
movement is called animation.
when clicked
Remember, blocks are
forever colour-coded. The “forever”
loop is in the orange
next costume Control blocks section.
dinosaur4-c dinosaur4-d
Choose
“dinosaur4-d”.
DINO DANCE PARTY 39
The “Spotlight ”
backdrop sets
Click this symbol the mood of
to add a backdrop. the party.
Choose a Backdrop
40 G E T T I N G S TA R T E D
wait 1 seconds
Looks
Events
forever
Control
Sensing
Choose a Sound
18 First, click on
Dinosaur2 in the Sprite Dinosaur2 x 20
sprites list to
show its code in Show Size 100
the code area.
move 10 steps
if on edge, bounce
Add this block to turn
the dinosaur round at
the stage’s edge.
forever
Select “left-right” in the
drop-down menu to keep move 10 steps
the dinosaur upright.
if on edge, bounce
42 G E T T I N G S TA R T E D
Keyboard control
Ever dreamt of taking control of your very own dinosaur? The
next bit of code will give you keyboard control of Dinosaur3’s
movements: you’ll be able to move the dinosaur across the
stage with the right and left arrow keys.
22 Click on Dinosaur3 in
the sprites list so you
can edit its code.
24 Before you run the code, read through it carefully and see
if you can understand how it works. If the right arrow key
is pressed, blocks that make the sprite point right and
move are run. If the left arrow key is pressed, blocks that
make the sprite point left and move are run. If neither is
pressed, no blocks are run and the dinosaur stays put.
DINO DANCE PARTY 43
EXPERT TIPS
Making choices
You make choices all the time. If you’re hungry,
you decide to eat; if not, you don’t. Computer
programs can also make choices between
different options. One way to make them do
this is to use an “if then” instruction, which is Is the right
arrow key Move right
used in lots of programming languages. In
pressed? Yes
Scratch, the “if then” block includes (true)
a statement or a question and only runs
the code inside the block if the statement
is true (or the answer is yes). No
(false)
Add a ballerina
The dinosaurs are dancing, but it’s not much of a party
without some friends. A ballerina is going to join the
fun and will do a routine. Her code will show you how
to create more complicated dance routines.
25 Click on the sprite symbol in the sprites list and load the
ballerina. Then use your mouse to drag the sprite to a good
spot on the stage. To give the ballerina some code, make
sure she’s selected in the sprites list – the selected sprite
has a blue outline.
Costume ballerina-a
1
Ballerina Ballerina is the
Fill Outline 2
selected sprite. ballerina-a
61 x 110
LINGO
Algorithms
An algorithm is a series ALGORITHM PROGRAM
of simple, step-by-step (Dance steps) (Dance steps turned into computer
instructions that together programming language)
carry out a particular task.
In this project, we converted
STAND!
the ballerina’s dance routine
(an algorithm) into a WAIT! switch costume to ballerina-a
program. Every computer
program has an algorithm wait 0.5 seconds
at its heart. Programming is
KICK! switch costume to ballerina-d
translating the steps of the
algorithm into a computer wait 0.5 seconds
WAIT!
programming language that
the computer understands. switch costume to ballerina-a
STAND! wait 0.5 seconds
BEND
THE KNEES!
DINO DANCE PARTY 45
EXPERT TIPS
Repeat loops and forever loops
Look at the bottom of the two types of forever repeat 10
loop you’ve used so far. Which one can
have blocks attached to it? You might
spot that the “repeat” block has a small
lug on the bottom, but the “forever” block
doesn’t. There’s no lug on a “forever” loop
because it goes on forever, so there’s no
point adding blocks after it. A “repeat”
block, however, runs a fixed number A lug allows you to
of times and the code then continues. join new blocks.
▽ Turn around
You can make any character face the other This makes
way by using a “turn 180 degrees” block. sure the
sprite stays
Just add this block before the end of the
upright.
“forever” loop to make your sprite’s dance when clicked
switch direction each time.
set rotation style left-right
forever
How it works
The aim of this two-player game is simply
to race across the screen and reach the
balloons before the other player. Fast
finger action is all you need to win.
The faster you tap the keyboard’s “z”
or “m” key, the faster your sprite moves
from left to right.
◁ Sending messages
This project shows you how
to use Scratch’s message
feature to make one sprite
pass information to other
sprites, such as when the
cat sprite tells the dog
and bat to start racing.
◁ Variables
The cat’s code stores
information in something
3 programmers call a variable.
In this project, you’ll use
a variable to store the
numbers for the cat’s count
at the start of the race. The cross and arrow
Count mark the start line.
ANIMAL RACE 49
The bat flaps its wings
every time you press
the “z” key.
Balloons mark
the finish area.
Catch me
if you can!
Operators
Cancel OK
My Blocks
My Blocks
Variables
when clicked
Make a Variable
Setting up the racers 8 Make sure Dog2 is selected in the sprites list.
Click on the Costumes tab at the top of the
The cat is ready to start the race. The next steps Scratch window and you’ll see it has three
are to decorate the stage for the race and then to costumes. The first two show the dog running,
add the bat and the dog sprites, along with other but we don’t need the third one so delete it.
sprites to mark the start and end of the racetrack.
The first two
1 costumes work
6 Add a backdrop. Click on the
backdrop symbol to the
well for this
project.
right of the sprites list and
add the “Blue Sky” backdrop. dog2-a
127 x 110
Click here to open
the backdrop library.
2
Choose a Backdrop
dog2-b
127 x 104
7
It’s time to add some sprites for the
Click here to
racers, starting with the dog. Click delete the third
the sprite symbol in the sprites 3 costume.
list. Find Dog2 in the library and
add it to your project.
dog2-c
121 x 109
Dog2 will now
appear in the
Sprite 1 Dog2 sprites list.
52 G E T T I N G S TA R T E D
go to front layer
Remember to choose
the yellow balloon
for the dog.
bat-a
159 x 120
bat-b
76 x 142
54 G E T T I N G S TA R T E D
when clicked
go to Bat Start
go to front layer
The race
The bat and the dog both need code to make them Go!
race. The cat will trigger these code blocks by sending
a message when it says “Go!” at the start of the race.
Both contestants will receive the message at exactly
the same time.
Cancel OK
broadcast message1
ANIMAL RACE 55
18 Now the cat sends out the “Start Race” message at the start
of the race. Each racer needs some code to make it react, so
select the dog first and add this code. See how the two “wait
until” blocks together make the player press the “m” key and
then release it again and again to move their character; just
keeping your finger on the “m” key won’t work.
move 10 steps This block checks if the Look for this block in the
Dog2 sprite is touching green Operators section.
next costume the “Dog Finish” balloon.
stop all
I won!
LINGO
Boolean operator: NOT
The “not” block reverses the answers to yes/no questions
answer to the question block (or true/false statements) in
inside it. This block is very useful useful ways: “not”, “or”, and “and”.
for testing if something isn’t Programmers call these “Boolean
happening. There are three green operators” and you’ll use all of
Operators blocks that can change them in this book.
56 G E T T I N G S TA R T E D
19 Run the project. Once the cat says “Go!”, you should find
that the dog runs forward a step each time you press and m... m... m...
release the “m” key. When it reaches its balloon, the dog
should stop responding. If anything isn’t working, carefully
check your code against the version in the book.
20 Next, add this similar code to the bat sprite. The only
differences are that the key selected now is the “z” key
and the bat must touch its own finish sprite.
move 10 steps
The bat stops running when
next costume it touches the balloon sprite.
stop all
▷ Sounds
Add a sound effect to mark the start of the race say Go!
by adding a “start sound” block to the cat’s code.
The cat has the “Meow” sound preloaded, but broadcast Start Race
you can load other sounds from the sound
library by clicking the Sounds tab and then the
speaker symbol . start sound Meow
Change 0 to 4.
◁ Countdown
set Count to 4
Try changing the middle part of the cat’s
repeat 3 code to look like this. Can you work out
Place a minus
sign in front of 1.
what will happen now?
change Count by –1
◁ Extra competitors
Why not add more animals to the race? Find some sprites
in the sprites library with costumes you can animate, like the
parrot or Butterfly 1. Add start and end sprites for each one
of them and adapt the racing code to use different keys. If
you need to adjust a sprite’s size, just add a “set size to” block.
58 G E T T I N G S TA R T E D
▽ Challenging controls
You can make the game harder for the players
by making them press two keys alternately FASTER, FASTER, KEEP
rather than one key repeatedly. You just need GOING STRAIGHT!
to change the code to wait for a second key
to be pressed and released after the first one.
This shows how to change the dog’s code.
For the bat, make the same change but
use “x” for the second key instead of “n”.
forever
move 10 steps
next costume
stop all
1 Choose Variables
in the blocks New Variable 2 Next add a “set Position to” block
to the bottom of the cat’s code
palette and then and change the number to 1.
click the “Make New variable name:
a Variable” Position say Go!
button to create
a new variable. For all sprites For this sprite only broadcast Start Race
Call it “Position”.
Cancel OK
set Position to 1
Change the
number to 1.
move 10 steps
next costume
think Position
Add these
two blocks.
1
change Position by 1
Choose “this script” in
stop this script the drop-down menu.
60 G E T T I N G S TA R T E D
Ask Gobo
Do you have a tricky decision to make The green flag
starts the project.
The red button
stops the project.
or want to predict the future? Let Gobo
help you in this fortune-telling project.
Here you’ll learn about random numbers,
variables, and how computer programs
make choices.
How it works
Gobo invites you to ask a question and
then answers with either “Yes” or “No”.
You can ask anything you like, from “Am
I going to be a billionaire?” to “Should I
play a computer game instead of doing
my homework?” Gobo pauses to look
like it’s thinking, but its answers are
actually pure chance.
◁ Gobo
Friendly Gobo is the only
sprite in this project. It has
three costumes that you
can use later to help bring
it to life.
◁ Take a chance
Just as the roll of the dice
creates random numbers,
Scratch can generate
random numbers to
make the program react
in unpredictable ways.
ASK GOBO 61
◁ Ask a question!
Gobo works best if you ask
it to make predictions or
decisions for you. Don’t ask
factual questions as it’ll often
get the answer wrong!
I can answer your
yes-or-no questions.
Click here to
delete the sprite.
Sprite1
set size to 250 % say Wait! The answer is coming to me... for 3 seconds
New Variable
Yes! No!
New variable name:
ReplyNumber
Type the
variable’s For all sprites For this sprite only
name here.
Operators
My Blocks
My Blocks
64 G E T T I N G S TA R T E D
EXPERT TIPS
Random numbers
A random number is one that you can’t
predict before it appears. A dice roll is a
random number – any of the numbers 4
1 Lowest number If you click on the
from one to six could appear each time
it can select. block it will tell
you roll the dice. You don’t know which you its value. It
number will come up until you roll. In selects a random
pick random 1 to 6
Scratch, you can get a random number number each time.
using the “pick random” block. Drag
this block into the code area and Highest number
experiment with it. it can select. 3 6
10 The variable will hold the number of Gobo’s reply, but the
program needs a way to choose that number randomly. Add a
1
“set my variable to” block to the bottom of Gobo’s code. Open 2
the block’s drop-down menu and select “ReplyNumber”. Then
drag a green “pick random” block into it from the Operators
section. Change the second number to 2. The green block
picks randomly between 1 and 2, like flipping a coin.
pick random 1 to 2
13 The code should now look like this. Run the project a
few times and check that Gobo gives random “yes” and
“no” answers. If not, check all of the code carefully.
Wait! The answer
is coming to me...
when clicked
wait 1 seconds
if ReplyNumber = 1 then
say Yes!
if ReplyNumber = 2 then
say No!
Make a Variable
Uncheck
the tick box.
my variable
ReplyNumber
66 G E T T I N G S TA R T E D
Am I a brilliant
programmer?
Should I be nicer
Should I do my to my sister?
homework right away?
EXPERT TIPS
More decisions
You’ve already seen how to use “if then” blocks There are three different green blocks you
containing questions to decide whether or can use to compare numbers, each with
not to run lines of code. In this project, you a different job and symbol: = (equal to),
use green Operators blocks inside “if then” > (greater than), and < (less than). Programmers
blocks to check the value of a variable. The call true-or-false decisions used inside “if then”
pale blue question blocks have “yes” or “no” blocks “Boolean conditions”. They are named
answers, but when you use the green blocks after the English mathematician George Boole
you should ask if what they say is true or false. (1815–1864).
▽ Ask me another say I can answer your yes-or-no questions. for 3 seconds
To make Gobo answer more questions after the say Ask your question then press space.
first one, place the original code inside a “forever”
wait until key space pressed?
loop, as shown here, with a few extra blocks to
make Gobo prompt the user for a new question. say Wait! The answer is coming to me... for 3 seconds
wait 1 seconds
say Yes!
when clicked
forever if then
ReplyNumber = 2
say No!
wait 3 seconds
▷ Special effects
You can alter Gobo’s replies to be more
fun. While you’re at it, why not make if ReplyNumber = 2 then
Gobo change colour or costume for each
reply? You could also add sounds to its say How DARE you ask that!
replies, some dance steps, or a spin.
switch costume to gobo-c
▽ More replies
To add to the fun you can extend the number of replies. You simply need
to increase the top number in the “pick random” block to the new number
of choices and then add extra “if then” blocks containing new “say” blocks. Change the 2 into a 6. This must
This example has six possible answers, but you can add as many as you like. match your number of replies or
some responses will never appear.
Yes!
if ReplyNumber = 1 then
say Yes!
if ReplyNumber = 2 then
No!
say No!
if ReplyNumber = 3 then
if ReplyNumber = 4 then
Definitely!
say Definitely!
if ReplyNumber = 5 then
if ReplyNumber = 6 then
when clicked
wait 1 seconds
wait 1 seconds
wait 1 seconds
say ReplyNumber
▷ Do as I say!
Rather than answering questions, Gobo could give Take a hike!
random orders, such as “run up and down the stairs”,
“jump in the air twice”, or “sing a famous song”. Just
change the text in the “say” blocks to Gobo’s commands.
You could also change Gobo’s appearance to something
grumpy to match the mood.
70 G E T T I N G S TA R T E D
Funny Faces
You can have lots of fun drawing your own sprites in
Scratch – you don’t have to stick to the ones in the sprites
library. Creating your own sprites will give your projects
a unique look. For this project, you can go wild making
facial features and accessories for a DIY face.
How it works
This project starts with a blank face surrounded by a
collection of eyes, noses, and other items that you can You can add up to 11
drag into the middle to create crazy expressions. Press eyes, but most sprites
the green flag to reset the face and start again. are just a single item.
Empty face
Bow tie
Mouth
F U N NY FAC E S 71
Pig nose
Snotty
nose
Tongue
72 G E T T I N G S TA R T E D
Get painting
Dust off your digital overalls because it’s time for some
painting. Scratch has a great paint editor built in, so you
have all the tools you need to create a mini-masterpiece
for each body part and item of clothing.
Costume costume1
Selected colour
Fill 10
Convert to Vector
F U N NY FAC E S 73
Fill tool
Head
74 G E T T I N G S TA R T E D
when clicked
go to x: 0 y: 0
EXPERT TIPS
Coordinates
To pinpoint any spot on the stage you can
use two numbers called coordinates. The
x coordinate, written first, tells you how far
the point is across the stage horizontally. y
The y coordinate, written second, tells 180
you how far the point is up or down the (–190, 110)
stage vertically. The x coordinates go from (130, 90) (215, 90)
–240 to 240. The y coordinates go from 90
–180 to 180. The coordinates of a point
are written as (x, y). The centre of the
(x:0, y:0)
bow tie on the right, for instance, has the x
coordinates (215, 90). –240 –120 0 120 240
(200, –80)
–90
Every spot on the stage has a unique (x:120, y:–90)
pair of coordinates that can be used
to position a sprite exactly. (–120, –100) –180
F U N NY FAC E S 75
Time to make lots of sprites
The more different eyes, noses, mouths, ears, hats, and
accessories your Funny Face project has, the more silly
faces you can make, so spend some time making as many
as you can. It’s great fun. You can also find useful items in
Scratch’s costumes library, such as hats and sunglasses.
You can skip the drawing stages for those.
Sprite Sprite1 x 20 y 80
To make round
eyes, use the circle
tool and hold down
shift. Fill with white
and add black
Head Eyebrow Eye spots for pupils.
Use the circle
tool to make a
pig’s nose.
Use the circle
tool to create an
open mouth. Add
teeth if you like.
Nose1 Hat1 Smile
Eyes
when clicked
go to x: 150 y: 100
Fill tool
Convert to Vector
Clones
You might want to use some sprites lots of
times – perhaps your face will be funnier with
10 eyes rather than two. Scratch allows you
to “clone” a sprite to make fully working copies.
EXPERT TIPS
Clones
13 Make 10 clones of the eye sprite
by adding this loop to its code.
Clones work a bit like the “stamp” block you
Now when you run the project
you can place all 11 eyes!
used in the Cat Art project. But while “stamp”
just draws a picture on the backdrop, the
clone block creates a working sprite. Clones
can be used for lots of clever things, as you’ll
when clicked see in later projects.
This loop creates 10
go to x: 200 y: 100 extra eyeballs on top
of the original.
create clone of myself
repeat 10
when clicked
Increase the number
go to x: 180 y: –30
to make the sunglasses
more transparent.
turn 1 degrees
▽Snotty nose
To make disgusting green snot drip out of
the nose, create two new costumes for the
nose with spots of green colour. Then add
these new blocks to make the snot drip.
costume1
Right-click the costume 53 x 55
and select “duplicate”
when clicked
to make copies.
go to x: 190 y: 25
costume2
53 x 59
switch costume to costume1
forever
when clicked
go to front layer
hide
TRY THIS
3 Now run the project. Make a silly face and then
check if you can make the frame appear and Try something different
disappear with the space-bar and “c” key.
You can use this project to create
anything from snowmen and Christmas
trees to monsters and aliens!
Art
82 ART
How it works H A P PY
When you run this project, a
mysterious flashing green button
appears. Press the button and an
animated birthday card fills the Happy birthday
screen, complete with singing sharks. to you!
The sharks take turns singing the
lines of the “Happy Birthday” song.
Click the button to open The sharks drop in from the top
the birthday card. and then sing “Happy Birthday”.
B I R T H D AY C A R D 83
T H DAY !
B I R
△ Gliding around
This project uses the “glide”
block, which makes sprites
move smoothly around
the stage. You need to use
Scratch’s coordinates system
to set the exact start and
finish point of each glide.
If you can’t remember how
coordinates work, see the
Funny Faces project.
△ Keeping time
Like Animal Race, this
project uses messages sent
from one sprite to another
to control the timing of
code blocks. The singing
sharks send messages back
The cake slides into view and forth to time their lines
from the edge of the stage. of “Happy Birthday”.
84 ART
Birthday button
To avoid spoiling the surprise of the card, all
that appears when the project is run is a message
and a button for the birthday person to press.
go to x: 0 y: 0
4 Scratch’s paint editor will now open. Choose the text tool and click
in the large white area, about a third of the way down. Type the words
“PRESS ONLY ON YOUR BIRTHDAY!” If you want to re-type the message
for any reason, use the select tool to draw a box around the text and
press delete on your keyboard before starting again.
Font menu
Code Backdrops Sounds
Costume backdrop1
1
Text tool
PRESS ONLY ON YOUR BIRTHDAY!
Select tool
Convert to Vector
Sans Serif
Resize the
text with
Sans Serif
these circles.
Serif
Handwriting
PRESS ONLY ON YOUR BIRTHDAY!
You can choose
Marker any font you like. Click and drag
Curly
this box to
move the text.
Pixel
86 ART
Choose a Backdrop
8
Make sure you still have the stage This block shows the
selected in the lower right of the white backdrop.
when clicked
Scratch window and not one of the
sprites. Click on the Code tab above
switch backdrop to backdrop1
the blocks palette and add these
code blocks for the stage. Now try The “Party” backdrop
running the project and see what with balloons appears
happens when you click the button. when I receive Go! when the button is pressed.
Sound Birthday
1
Cake
Birthday
7.32
B I R T H D AY C A R D 87
Birthday banner
The next thing needed for a party
atmosphere is an animated birthday
banner that rocks back and forth. Click here.
Paint
Costume costume1
Fill
Filled Outlined
Selected
colour
Rectangle
tool
Text tool
HAPPY BIRTHDAY!
Convert to Vector
B I R T H D AY C A R D 89
turn 20 degrees
Use the blue “turn”
blocks to make the wait 1 seconds
banner turn.
It then turns
anticlockwise.
EXPERT TIPS
Directions
Scratch uses degrees to set the
direction of sprites. You can
–90° moves a 0°
sprite straight
choose any number from –179° to the left.
to 180°. Remember, negative
numbers point sprites left and
positive numbers point them
right. Use 0° to go straight up
and 180° to go straight down. –90° 90°
180°
90 ART
Singing sharks
What’s the perfect finishing touch to a birthday surprise?
Yes, of course... singing sharks! The two sharks will take
turns singing by sending messages to each other after
each line of the song.
Click here to
rename the sprite.
delete
Click here to create
the second shark. export
The shark
starts out with
when I receive Go! a costume when I receive Go!
that has its
show mouth closed. show
19 Time to get the sharks singing. Remember the loop belonging to the cake sprite
that plays “Happy Birthday”? It sends the message “Line1” every time the song
starts. Add the code shown on the left to Shark1 and the code on the right
to Shark2 to make them react to the message. More messages make them take
turns to sing each line. You’ll need to create new messages for each line of the
song. Name them by using the drop-down menu in the “broadcast” blocks.
Shark1
when clicked
hide
hide show
repeat 50
change size by 5
when I receive Go!
△ Adding photos
Why not try importing a photo of the birthday boy
or girl into the project? You can upload any picture
you like to make a new sprite by clicking the upload
symbol in the sprites menu. But don’t share projects
containing people’s photos without their permission.
Happy birthday
to you...
Upload Sound
Record a sound
Upload a sound
Record
△ Adding sound
You don’t have to use Scratch’s built-in sounds and songs – △ Birthday dancers
you can add your own music or record your very own version Why not reuse some of your dancers from the
of “Happy Birthday” if you want. Click the upload symbol Dino Dance Party in your birthday card? If you
in the sounds menu to add a sound file from your computer. do, adjust the timing of the costume change
Click the microphone symbol to record your own sounds. so they dance in time to the music.
94 ART
Spiralizer
Try out this spinning spiral project. Adjust the sliders to
Change the patterns using special change the look
of the spiral.
sliders to alter the values of variables
in the code. You control the art – the
possibilities are endless!
Angle 10
How it works
Speed 2
This simple project has only one sprite: a
coloured ball, which stays in the middle.
Scratch’s clone blocks make copies of the
ball that move outwards in straight lines.
A spiral pattern forms because each clone
moves in a slightly different direction, like
water from a garden sprinkler. The Scratch
pen draws a trail behind each clone, making
colourful background patterns.
△ Clones
Clones are working copies
of sprites. When a clone is
created, it appears on top
of the existing sprite and
has the same properties,
such as direction, size,
and so on.
△ Scratch pen
Every sprite can draw a
trail behind it wherever
it goes – just add the
green “pen down” block
to its code. By adding
the Pen extension you
get extra blocks added
to the blocks palette to
change the pen’s colour,
shade, and thickness.
96 ART
forever
when clicked This shrinks
the ball.
move 2 steps
set size to 30 %
This block moves
go to x: 0 y: 0
the ball to the
centre of the stage.
forever ▷ What’s going on?
The parent sprite changes its
create clone of myself direction a little before each clone is
created. As a result, the clones move
turn 10 degrees off in slightly different directions,
one after another. Each clone travels
Each time this
block runs, a new
in a straight line to the edge of the
clone is made. stage, making the clones form an
ever-expanding spiral pattern.
Taking control
There are two numbers in the ball’s code that you can change to alter
the spiral’s appearance. One is the change in the angle before each new
clone appears. The other is the number of steps in the “move” block,
which determines the clones’ speed. If you create variables for these
numbers, Scratch lets you add a slider control to the stage so you can
change them while the project is running. This makes experimenting easy.
My Blocks
Click “OK”.
98 ART
Speed 0
Variables
Make a Variable
Angle
my variable
Speed
when clicked
Angle 10 Angle 10
set Speed to 2
set size to 30 %
This block removes
all pen trails so the go to x: 0 y: 0
stage starts blank.
forever
erase all
create clone of myself
This activates set pen size to 1
the pen so turn Angle degrees
that every pen down
clone leaves Type 1 in here
a trail. for a thin pen.
Angle 10 Angle 7
Speed 2 Speed 2
SPIRALIZER 101
when clicked
set Angle to 10
set Speed to 2
set size to 30 %
go to x: 0 y: 0
erase all
pen down
forever
Angle 10 Angle 31
Speed 2 Speed 10
Pen size = 1, Angle = 10, Speed = 2 Pen size = 1, Angle = 31, Speed = 10
Angle 10 Angle 10
Speed 2 Speed 2
Pen size = 10, Angle = 10, Speed = 2 Pen size = 100, Angle = 10, Speed = 2
SPIRALIZER 103
forever
These hide
the sliders.
show Remember
that these code
show variable Angle blocks run for
all the clones
on the stage.
show variable Speed
◁ Ball control
Instead of generating clones in a spiral pattern, you
can make them follow the mouse-pointer. Just replace the
Angle 10
“turn” block with a “point towards mouse-pointer” block.
Speed 2
Now try painting with the mouse.
TRY THIS
Clone lab
Experiment with clones to get a feel for how they a “go to x: y:” block to see some crazy effects.
work. Start a new project and add a clone creation You can even add some keyboard controls and
loop to the cat and give each clone a simple bit sound effects for fun. Once you’ve mastered
of code to run when it starts. Experiment with clones, you’ll find you can do all sorts of things in
a “pen down” block or put random numbers in Scratch that are almost impossible without them.
if on edge, bounce
106 ART
Fantastic Flowers
Create a virtual meadow and fill it Click the green flag
to start the project.
with colourful flowers. In this project,
you’ll learn how to make your own
customized Scratch blocks. Each time
one of these runs, it triggers special
code called a subprogram, which
paints a flower.
How it works
When you run the project, a flower appears
wherever you click the mouse. Scratch uses
a simple ball sprite and a “stamp” block to
draw each flower. The ball stamps an image
of itself to create each petal, moving back
and forth from the flower’s centre each time.
draw flower
△ Subprograms
Scratch lets you create your own custom blocks
to trigger code that you’ve already built. Then,
instead of having to make that code every time
you need it, you simply use the new block.
Programmers use this trick all the time and
call the reused code a subprogram.
△ Adding inputs
You can create blocks that have windows for
inputting numbers or other information, like
the example shown here, which lets you set
the number of petals.
FA N TA S T I C F LO W E R S 107
I think it must
be spring!
108 ART
2 Build and run this code to draw a simple flower with five petals.
The loop runs five times, drawing a ring of petals centred on the
ball sprite’s starting position. Each petal is a “stamp” image of
the ball sprite. Remember, you’ll need to add the Pen extension
using the “Add Extension” button at the bottom left.
repeat 5
It moves back It then turns to face a new
move 25 steps to the centre. direction. There are 360 degrees
in a full circle, so each turn is
stamp
one-fifth of a circle.
move –25 steps 4 5
EXPERT TIPS
Doing maths
Computers are very good at maths. You can Add Subtract
use the green Operators blocks in Scratch to
do simple sums. For more complex calculations, + –
you can also put Operators blocks inside each Divide
other or combine them with other blocks. If
blocks are put inside each other, the computer * /
works from the innermost blocks outwards,
as if the inner blocks were in brackets. Multiply (Computers usually
use a * sign to avoid confusion
with the letter x.)
FA N TA S T I C F LO W E R S 109
More blocks
The next step is to turn the flower-drawing
code into a flower-drawing block. You
can then use this block to grow flowers
wherever you want.
Type the name of the
new block here.
My Blocks
text
Make a Block
Add an input Add an input Add a label
number or text boolean
Click here to
create the
Run without screen refresh
new block.
Cancel OK
move 25 steps
stamp
define draw flower
move –25 steps
stamp
110 ART
go to mouse-pointer
draw flower
stamp
draw flower
text
Cancel OK
112 ART
text
Cancel OK
move 25 steps
Drag the “number
stamp of petals” block into
these two places.
move –25 steps
stamp
FA N TA S T I C F LO W E R S 113
when clicked
forever
go to mouse-pointer
draw flower 7
when clicked
Click here if you want to
delete an input window.
forever
Make a Block
if mouse down? then
go to mouse-pointer
draw flower number of petals petal colour centre colour
draw flower 7
text
Cancel OK
pick random 5 to 10
move 25 steps
set color effect to petal colour
stamp
stamp
go to mouse-pointer
when clicked
erase all
forever
In Scratch, colours go
if mouse down? then from –100 to 100.
go to mouse-pointer
pick random –100 to 100
draw flower 6 70 100
pick random 5 to 10
Flower stalks
Real flowers grow on stalks, so follow the next few steps to
add stalks to your virtual flowers to make them look more
realistic. Using custom blocks makes the code easy to read
so you always know what’s going on.
Make a Block
text
Cancel OK
change y by length
when clicked
erase all
Stalk length
forever
draw flower pick random 5 to 10 pick random –100 to 100 pick random –100 to 100
Blue Sky
480 x 360
Playing Field
480 x 360
118 ART
▷ Different petals
6
Why not use the costume editor to add a different
petal to the flowers? Click on the Costumes tab
and add a new costume with the paint symbol .
Oval petals work well. You’ll need to add blocks
petal2
to the “define draw flower” code to swap between 72 x 22
the petal costume and the ball-a costume for the
flower’s centre.
▽ Flowers everywhere
Try swapping the main code for this one. It draws
flowers in random places automatically, eventually
covering the stage with them. Think about how
you could add position inputs to the “draw flower”
when clicked The chosen ranges block – you’d need to add x and y inputs and add
keep the flowers a “go to” block at the start of the block’s definition.
erase all away from the edges.
forever
draw flower pick random 5 to 10 pick random –100 to 100 pick random –100 to 100
FA N TA S T I C F LO W E R S 119
Different sizes
By adding another input to the “draw flower”
block, you can control the size of your flowers. 1 Right-click the “define” header to edit it and
add a new input called “scale”. Make the
changes shown below to the code. When
You can also make the meadow look more 3D scale is set to 100 in the “draw flower” block,
by making the flowers smaller if they’re near the flowers are drawn at their usual size.
the top of the stage, as though further away. Smaller numbers will produce smaller flowers.
define draw flower number of petals petal colour centre colour scale
stamp
go to mouse-pointer
Tunnel of Doom
Scratch is the ideal playground for making and
perfecting games. To win at this game, you need The cat starts here.
How it works
Use your mouse to move the cat all the way through
the tunnel without touching the walls. If you
accidentally touch a wall, you go back to the start.
You can try as many times as you like, but the clock
will keep counting the seconds until you finish.
◁ Cat sprite
Once the mouse-pointer has
touched the cat, the cat follows
it everywhere. You don’t need
to use the mouse button.
◁ Tunnel
The tunnel maze is a giant sprite that
fills the stage. The tunnel itself isn’t
actually part of the sprite – it’s a gap
that you create by using the eraser tool
in Scratch’s paint editor. If the cat stays
in the middle of the path, it won’t be
detected as touching the tunnel sprite.
◁ Home
When the cat touches the home sprite,
the game ends with a celebration.
TUNNEL OF DOOM 123
Do you dare
to enter the
“Tunnel of Doom”?
Will your time
Time in seconds be the fastest?
Time 201
Sprite Cat x 0 y 0
Sprite1
Cat
Blue highlight indicates
the sprite is selected.
Click here to
preview a sound.
TUNNEL OF DOOM 125
Fill tool
Eraser tool
7 Use the eraser to make gaps in the top left and top right
where the maze starts and ends. Then draw a wiggly tunnel
between the two corners. If things go wrong, click the undo
symbol at the top and try again. Make sure the eraser
is nearly full size.
Costume costume1
100
Fill Start position.
End position.
The tunnel
should be
chequered,
not white. Convert to Vector
Tunnel forever
Mouse control
Now add some code to the cat to turn the
project into a working game. The code blocks
build step by step, so test them as you go
along to check they work properly.
11 Select the cat sprite and add this code. It shrinks the cat
and positions it at the start of the tunnel. Once the mouse-
pointer touches the cat, it will move with the mouse. Note
that players don’t need to click on the cat to pick it up. The
code stops with a “Meow” if the cat touches the tunnel walls.
EXPERT TIPS
Repeat until loops
The useful “repeat until” loop
repeats the blocks inside it until
when clicked
the condition at the top of the
block becomes true, and then repeat until touching Bone ?
the blocks below are run. The block
makes it easier to write simple, dig
readable code, like this example.
eat bone
Unlike the “forever” block,
“repeat until” has a bump at
the bottom allowing more
blocks to be added to it.
12 Run the game. You should be able to control the cat once
you’ve touched it with your mouse-pointer. Try moving it
along the tunnel. If you touch the wall, the cat will meow
and get stuck. If the cat gets stuck too often, reduce the
number in the “set size” block, but don’t make it too easy.
TRY
AGAIN!
Drag the top of the “forever”
block above the “go to” block when clicked
and it will expand to fit
around all the blocks below.
set size to 20 %
go to front layer
forever
go to x: –210 y: 160
go to mouse-pointer
go to x: –210 y: 160
Well done!
You did it!
To draw perfect
circles, hold shift
when you use
this tool.
132 GAMES
show
go to front layer
forever
Window Cleaner
Messy windows? You’d better get up and clean them!
This frantic game counts how many splats you can
clean off your computer screen in a minute. You
can wipe away the splats either by using a computer
mouse or by waving your hand in front of a webcam.
How it works
The game starts by cloning a splat sprite and scattering ▽ Splat sprite
clones with different costumes randomly across the stage. This game has one sprite
with several costumes,
When motion is detected by the webcam, Scratch uses
which you’ll paint yourself.
its “ghost” effect to make the splats fade. If you wave your By cloning the sprite you
hand enough, they eventually disappear. The aim of the can cover the screen with
game is to remove as many splats as you can in one minute. splats of messy gunk.
Score 42
Countdown 8
△Controls
First you’ll clean up the
splats with your mouse,
but later you can change
the code to detect the
Each splat is a clone of Wave your hand to movement of your hand
the project’s single sprite. rub out the splats. with a webcam.
WINDOW CLEANER 135
Slime time!
To make some mess on the screen, you need to
draw some slimy splats. Follow these instructions
and you’ll be in a mess in no time at all.
Brush tool
Convert to Vector
136 GAMES
Vanishing splats
Now it’s time to add code to the splat sprite to make the game
work. Follow the next steps to make several clones appear
and then disappear when the mouse-pointer touches them.
set MaxSplats to 10
set SplatsOnScreen to 0
set Score to 0
forever
Goodbye, splat!
wait 1 seconds
Tick down
a second.
change Countdown by –1
show
repeat 5
Score 42
Countdown 8
It’s easier to
play this game in
full-screen mode.
slider
if costume # = 1 then
Difficulty 40
Each costume colour will need
an “if then” block like this.
Simulations
144 S I M U L AT I O N S
Virtual Snow
You don’t want real snow inside your computer –
it would melt and ruin the circuits. This project
shows you how to make perfectly safe virtual
snow using Scratch. It falls from the sky and
can be made to settle on the ground or stick
to things.
How it works
Each snowflake is a clone that moves down
the stage from top to bottom, jiggling from side
to side like a real snowflake. When the snowflake
lands on something or hits the bottom, it stamps
an image of itself.
The snowflakes are clones
of a simple circle shape.
△ Snowman
In this project, you can load any
sprite and make snow stick to it.
The snowman sprite works well.
△ Hidden pictures
You can add invisible objects that
slowly reveal themselves as the
snow sticks to them. Use a sprite
from the library, draw your own
Snow falls from the top The snow piles object, or write your name in
and settles at the bottom. up on the sprite. huge letters.
VIRTUAL SNOW 145
Let it snow
Start off by drawing the snowflake costume,
which is simply a white circle. Then make it snow
by creating clones – each one a tiny snowflake
falling from the top to the bottom of the stage.
Type “Snowflake”
here.
Choose solid
colour here.
Circle tool
Convert to Vector
146 S I M U L AT I O N S
3 To make sure the circle is the right size, drag one of the
corners of the box that appears around it to resize the
circle. Aim for a size of 50 x 50. If the box disappears,
use the select tool to draw it around the circle again.
Costume Costume1
1
Fill
costume1 Copy Paste Delete Flip horizontal Flip vertical
50 x 50
The costume’s
size is shown
here.
Select tool
Convert to Vector
Costume backdrop1
Fill
Fill tool
The background
fades from dark
blue to a paler blue.
Convert to Vector
set size to 10 %
This shrinks
forever the snowflake.
stamp
Click here and choose white
delete this clone from the colour palette.
There’s no business
12 Run the project and watch the snow
pile up. You’ll notice a problem. The
like snow business!
snowflakes are building up in beautiful
sculptures rather than settling in a
blanket, as real snow does.
Snowflakes stick to
anything white.
150 S I M U L AT I O N S
stamp
pick random 1 to 6 = 1
delete this clone
stamp
stamp
Secret pictures
It’s easy to modify this project so that the snow
sticks to an invisible object, slowly revealing it. Save
your project as a copy before you try doing this.
go to x: 0 y: 0
Put the number of
costumes here.
152 S I M U L AT I O N S
show
The snow no longer
forever
settles at the bottom
change y by –3 of the stage.
A 1 in 20 chance of
if y position < –175 then
sticking lets snow
fill the whole shape.
delete this clone
stamp
Snow sticks to the
delete this clone ghosted sprite.
How it works
Click anywhere on the stage to make a
rocket shoot up to that point and explode
into a colourful firework. Each firework
consists of hundreds of clones of a single
sprite. The project uses simulated gravity
to make the clones fall as they fly outwards,
while flickering or fading.
◁ Rocket
Each firework starts off as a rocket
launched at the click of a mouse.
You can use a simple coloured line to
represent the rocket or create a more
detailed one in Scratch’s paint editor.
◁ Clones
To create the globes of coloured
“stars”, this project uses 300 clones,
the maximum number that Scratch
allows. Each clone follows a slightly
different path at a slightly different
speed to make the stars spread out
in a circle.
F I R E W O R K D I S P L AY 155
Each explosion is
made up of hundreds
of clones that spread
out from the rocket.
Creating the rocket 1 Start a new project and delete the cat sprite by
right-clicking on it and then selecting “delete”.
The first step in the project is to create Click on the paint symbol in the sprites menu
the small rocket that shoots up into the to create a new sprite and open the paint editor.
sky and explodes in a blaze of fireworks. Rename the sprite “Rocket”.
The code will make the rocket fly to
wherever you click the mouse-pointer.
Convert to Vector
costume1
10 x 50 Click here to select
the backdrop.
F I R E W O R K D I S P L AY 157
Convert to Vector
when clicked
The loop pauses
6 Next, select the rocket sprite and
add this code to make it shoot up
to wherever the mouse is clicked.
hide until the mouse
is clicked.
forever
The rocket starts at the
wait until mouse down? bottom, directly under
the mouse. This block makes
go to x: mouse x y: –180 the rocket move
smoothly upwards.
show
hide
broadcast Bang
Choose “New message” The stage turns white
and call it “Bang”. for an instant.
Costume
Costumes
Stars
Sounds
Convert to Bitmap
hide
1
repeat 300
Speed of
slowest stars
when I receive Bang
Speed of
set speed to pick random 0.1 to 3 fastest stars
show
The stars spread out
repeat 50 in every direction.
▽ Sticky stars
You might sometimes see a trail of stars in a line if you send up a rocket
straight after running the project. This happens if the stars explode
before all the clones are created. To fix the bug, add a “broadcast” block
to the bottom of the “when flag clicked” code in the stars sprite and
change the rocket’s code to run only after it receives the message.
hide hide
forever
repeat 300
wait until mouse down?
create a clone of myself
go to x: mouse x y: –180
show
hide
broadcast Bang
▽ Changing colours
Firework-makers use chemicals to create different
The colours
colours. Try this hack to the stars sprite to make change as the
the colours change as the firework explodes. firework expands.
▷ Gravity trails
To make the stars arc downwards when I receive Bang
under the pull of gravity, leaving
set speed to pick random 0.1 to 3
colourful trails in their wake,
rebuild the code as shown here. set ghost effect to 0
Remember to delete the original
change color effect by 25
code when you’ve finished. As
the timer increases, the stars pen up
The pen creates
fall more quickly, which is how go to Rocket the trails.
gravity really works. See if you
can figure out how to change the pen down
colour of the trails or make them point in direction pick random –180 to 180
brighten or fade out (hint: you’ll
need to add the Pen extension). show
reset timer
repeat 50
This sets the timer
to 0. It then counts move speed steps
up in seconds.
change y by 0 – timer
change y by 0 – timer
Fractal Trees
You might think that drawing a tree
requires an artistic eye and a lot of Each leaf is a clone of
fiddly work, but this project does the the Scratch ball sprite.
How it works
When you run the project, a tree grows in
a split second from the ground up. The tree
is a fractal – a shape made from a repeating
pattern. If you zoom in to just a part of a
fractal, it looks similar to the whole shape.
This repetition is easily generated in
a computer program by using loops.
Branches are
drawn with the
Scratch pen.
This section looks
like a miniature
version of the
whole tree.
F R AC TA L T R E E S 163
Romanesco broccoli
△ Fractals in nature
Lots of natural objects have
fractal shapes, including
trees, river systems, clouds,
blood vessels, and even
broccoli. Natural fractals
form most often when
something keeps dividing
into branches, which is how
trees and blood vessels grow.
164 S I M U L AT I O N S
How it works
In the project Dino Dance Party, we saw how the ballerina’s
dance routine is based on an algorithm – a set of simple
instructions that are followed in strict order. In this project,
the code that draws the tree is also based on an algorithm.
Try following the three steps below with a pen and paper.
Variables
Make a Variable
my variable
ShrinkFactor
F R AC TA L T R E E S 165
when clicked
erase all
pen up
set size to 10 %
set Angle to 30
These three variables
set Length to 90 set how the tree looks.
go to x: 0 y: –170
▽ Different angles
Try experimenting with the value of “Angle” in the first orange block. You could also
add a “pick random” block to generate randomly shaped trees. If you want to keep
trees looking natural, set the minimum and maximum to 10 and 45. To make playing
with the variable easier, check its tick box to show it on screen and turn it into a slider.
You’ll need to delete the “set Angle” block from the code if you do this.
▽ Ever-changing angles
If you move the “set Angle” block inside
the “repeat” loop, the angles between
branches will change as the tree grows.
repeat 8
broadcast
set Angle to pick random 10 to 45
Angle = 30
Length = 90
ShrinkFactor = 0.5
Grow a forest
You can adapt this project to grow trees wherever
you click, covering the stage with a forest. Make
the following changes to the code to do this.
when clicked
erase all
forever
set size to 10 %
The branches are shorter
set Angle to 25
to make the trees smaller.
set Length to 30
point in direction 0
pen down
repeat 8
Snowflake Simulator
Snowflakes are famous for their
amazingly varied shapes – it’s said
that no two are the same. Even
so, all snowflakes share the same
underlying structure, with six similar
sides. This pattern, known as six-fold
symmetry, makes snowflakes easy
to mimic on a computer. You can
use the same technique as in the
Fractal Trees project, but this time
every shape will be unique.
How it works
When you run this project, a snowflake
appears on the stage. Later you can make
snowflakes appear wherever you click.
Each snowflake is a bit like a fractal tree
with six trunks. By using random numbers
to set the lengths and angles of the white
lines, you can create an endless variety
of unique shapes – just like in nature.
S N O W F L A K E S I M U L AT O R 173
△ Real snowflakes
Snowflakes are six-sided because
they grow from ice crystals, which
are hexagonal. As a snowflake
grows, slight changes in air
temperature affect the way ice
crystals build up. Because every
snowflake follows a different
path and experiences different
changes in temperature, every
snowflake is unique.
△ Snow-FAKE
The drawing starts with six versions
of the sprite to match the six-fold
symmetry of a real snowflake.
After that, the lines split in two
repeatedly, like the fractal tree,
but with more varied angles.
174 S I M U L AT I O N S
Symmetrical branches
To see how this project uses the ideas from Fractal
Trees to make a snowflake, start by following these
steps to create a simple, non-random snowflake.
Events Levels
my variable
Control
Symmetry
Sensing
SymmetryAngle
Operators
Variables
go to x: 0 y: 0
This calculates the angle
between each arm.
pen down
repeat Symmetry – 1
The loop adds five
create clone of myself clones pointing in
different directions.
turn SymmetryAngle degrees
when clicked
set Symmetry to 6
erase all
set Levels to 4
set pen color to
go to x: 0 y: 0
pen down
repeat Symmetry – 1
Change “Length”
to 20 for now.
set Length to 20
set Angle to 15
Add a new loop to
create the branching broadcast Draw Level and wait
pattern on each arm.
S N O W F L A K E S I M U L AT O R 177
Use full-screen
mode to see a bigger
snowflake up close.
repeat Levels
▷ Oddflakes
set Length to pick random 30 to 150
Try this quick change
to make odd-looking
snowflakes. It varies repeat Levels
the line lengths after
each branch point,
creating a wider range set Angle to pick random 140 to 180
of flaky weirdness.
broadcast Draw Level and wait
Move the “set Length to”
block into the “repeat” loop.
S N O W F L A K E S I M U L AT O R 179
▽ Click-a-flake
Make snowflakes wherever you click
on the stage with these modifications
to the code. There’s also code to clear the
stage when you press the space-bar in
case things get too messy. Make sure
you keep the code from step 7.
Snowflakes appear
wherever you click.
when clicked
set Symmetry to 6
set Levels to 4
erase all
pen up
Replace the old “go to”
go to mouse-pointer block with this new one.
pen down
repeat Symmetry – 1
Change the numbers to
create clone of myself make the snowflakes smaller.
This code clears the
turn SymmetryAngle degrees
stage of snowflakes.
broadcast Kill All Clones and wait when I receive Kill All Clones
Add this block so Scratch
delete this clone
won’t run out of clones.
Music and
sound
182 MUSIC AND SOUND
How it works
Sprites and Sounds couldn’t be easier to play – simply ▽ Virtual circus
click the sprites or the background and you’ll hear This entertaining project is a
mix of funny sounds and moves.
a sound and see an animation or visual effect. You can add as many sprites and
sounds as you want to spice up
the show.
Each sprite performs
its own little show
when clicked.
The project works
best in full-screen
mode, which
stops you from
accidentally
moving the sprites.
Click anywhere
on the stage for
some sound
and action.
SPRITES AND SOUNDS 183
Background action All together
Everything in this project does something now!
interesting when it’s clicked, including the
background. Follow these steps to create
the background, and then start adding sprites.
Stage 2
Fairydust
0:51
Backdrops
2 The blue outline
shows that the This sound is 0.51
stage is selected. seconds long.
Sprite extravaganza!
Now add the following sprites and their code blocks. Some of the sprites have the
right sounds built in, but in other cases you’ll need to open the Sounds tab and
load the sound from Scratch’s sound library before you can select it in the code.
After building each bit of code, position the sprite on the stage and test it.
7
This lights
the candles.
when this sprite clicked
repeat 4
turn 30 degrees
point in direction 90
8 9
Elephant Dog2
This is the
Elephant fanfare elephant’s Barking dog
trumpeting
costume.
repeat 16
repeat 6
The horse runs
back and forth. move 5 steps
The “bubbles”
sound is loaded
by default.
wait 1 seconds
The fish flips
left and right point in direction 90
calmly while the
bubbles make a wait 1 seconds
gurgling sound.
SPRITES AND SOUNDS 187
Lion Monkey
repeat 10
King of the jungle Jumpy monkey
change y by 10
Cheesy puffs
The last sprite is a bowl of tasty-looking cheesy puffs –
when you click on the bowl, the cheesy puffs will vanish.
There isn’t a suitable costume for the empty bowl, but you
can create one using Scratch’s paint editor. The following
steps show you how.
wait 1 seconds
Click the
square to stop
recording.
Re-record
Play Save
Stop recording
1 Sound recording1
Trim
Meow2
0:29
recording1
00:00
Drumtastic
This project turns your computer keyboard into a drum
machine. Type in anything you want and Scratch turns
the letters into repeating drum sounds using up to
18 different instruments, from cymbals and bongos
to pounding bass drums.
▽ Scratch drumkit
How it works The code turns every letter
When you run the project, the Scratch cat asks you to into a drum sound. There are
26 letters in the alphabet but
type something in the box. When you press return, the Scratch only has 18 drum
code turns each letter into a different sound and plays sounds, so some sounds
the phrase back over and over again. As the sounds are used for two letters.
play, the coloured drums on the stage flash in time,
while the Scratch cat walks to the beat.
A
Snare drum
Count 30
Words Scratch
B
Bass drum
C
Each drum Side sticks
lights up as
it’s played.
Make a Block
Click here
to open the
paint editor.
play a drum
Paint
Make a Block
Cancel OK
My variable
Words
Click “OK” to
Choose this option. complete the block.
192 MUSIC AND SOUND
5 Next add this code to the “define play a drum” header block.
For now, the cat just says the letter and the code plays only
LINGO
one type of drum: a snare drum. The code will get longer later Strings
so that different drums can play. Add the Music extension by
clicking “Add Extension” at the bottom left and choosing Programmers call a sequence of
“Music” to use the play drum blocks. words or letters a string. Think
of the letters as being strung
together like beads on a necklace.
when clicked
ask Type something to make a drum sequence. Then press return. and wait
change Count by 1
With each loop, a different letter
is set as the input in the “play a
drum” block.
On to the
next letter.
D R U M TA S T I C 193
s c r a t c h
From letters to drums play drum (1) Snare Drum for 0.25 beats
The next step is to change the code
so that each letter plays a particular (1) Snare Drum a, s
drum. Scratch has only 18 drum
sounds, so some sounds will be (2) Bass Drum b, t
played by more than one letter. (3) Side Stick c, u
Spaces and punctuation will create Scratch’s
(4) Crash Cymbal d, v
brief pauses in the pattern of drums. “play drum”
block has
Scratch also ignores whether letters 18 built-in (5) Open Hi-Hat e, w
are capitals or not – “A” and “a” are sounds.
(6) Closed Hi-Hat f, x
treated the same.
(7) Tambourine g, y
(8) Hand Clap h, z
forever
set Count to 1
change Count by 1
next costume
set ChosenDrum to 0
play drum (1) Snare Drum for 0.5 beats
set AlphabetCount to 1
Start
at “A”. length of Alphabet
Delete the block.
repeat
Is the chosen
number
change AlphabetCount by 1 On to the next
bigger than letter of the
the number alphabet.
if ChosenDrum = 0 then
of drums?
Move it back rest for 0.25 beats No drum picked? Just
into range. take a short break.
D R U M TA S T I C 195
Light-up drums
To make the project look more
interesting you can add a circle
of 18 coloured drum clones –
one for each sound. Each drum
will light up when its sound plays.
Drum
hide
set ChosenDrum to 0
set drumID to 1
set size to 50 %
point in direction 90
Each drum is a
repeat NumberOfDrums different colour.
go to x: 0 y: 0
Next drum
d
b
change tempo by 2
change tempo by -2
Mindbenders
200 MINDBENDERS
How it works
I am
The spots take turns to disappear and reappear very quickly, number 5!
causing a gap in the circle that races round. This confuses
your brain, which fills in the missing spot with a different
colour, creating a magic green spot that doesn’t exist. Keep
watching and the magic green spot will erase all the pink
spots, but this is just an illusion too! △ Clones with identity
Keep your eyes fixed
Each circle is a clone. In this project,
on the cross to see This illusion works best you’ll see how each clone can have
the illusion. in full-screen mode. its own copy of a variable – in this
case, an ID number that’s used to
control which circle is hidden at
any moment.
costume1
Hold down the 80 x 80
shift key to avoid
making an oval.
The numbers
tell you the
costume’s size.
202 MINDBENDERS
Zooming in makes
drawing the cross easier.
Convert to Vector
Circle of clones
Now to fill in the background and create the circle
of clones. The code will give each clone a unique Click here to
identification number that will make it easy to hide. create a new
backdrop.
turn 30 degrees
when I start as a clone
change id by 1
say id
The clone is given
a unique number.
204 MINDBENDERS
10 2
The original
sprite doesn’t
run the “say”
block.
3
9
2 8 4
1 3
7
6
5
Cancel OK
Make sure this
option is selected.
THE MAGIC SPOT 205
when clicked
when I receive Hide Spot
switch costume to Spot
go to x: 0 y: 0 if id = Hidden then
set id to 0 else
repeat 12 show
turn 30 degrees
change id by 1
set Hidden to 0
The “Hidden” variable
forever controls which spot hides.
change Hidden by 1
if Hidden = 12 then
The “Hidden” variable
counts up to 11 and set Hidden to 0
then jumps back to 0.
This number controls the wait 0.1 seconds Open the menu and
speed at which the magic create a new message
spot moves around the circle. called “Hide Spot”.
206 MINDBENDERS
16 Run the project. You should see the gap move around the circle. Put the
stage into full-screen mode and stare at the cross. Within a few seconds,
you’ll see the magic green spot. Keep staring at the cross and the magic Stare at the cross
spot will start to erase the pink spots. When you look away from the to see the illusion.
cross, you’ll just see the empty gap again.
EXPERT TIPS
If then else
The “if then” block is very useful for either
running or skipping a group of blocks
depending on the answer to a question. But
what if you want to do one thing for yes (true) Does my
and another for no (false)? You could use two id = “Hidden”? Hide
“if then” blocks, but programmers face this Yes
problem so often that they created another (true)
No
solution: “if then else”. The “if then else” block (false)
has two jaws, for two sets of blocks. The top
set runs on yes, the bottom set runs on no. Show
THE MAGIC SPOT 207
hide
else
show
△ Colour controls
To find out which colours make the illusion strongest,
create a new variable called “SpotColour” and add a slider
to the stage. Add a “set color effect” block to the sprite’s
code under the “when I receive” block. Run the project
and try different colours. Which ones work best? Does
the magic spot change colour too?
TRY THIS
Speed it up
Try adding a new variable, called “Delay”, to
set the speed of the magic spot. You’ll need to
add these two blocks to the code – see if you set Delay to 1
can figure out where to put them. Right-click
(or control/shift-click) on the variable on the
stage and choose “slider”. Does the illusion wait Delay / 100 seconds
still work if you slow it right down?
208 MINDBENDERS
The coloured
line thickens
in response
to loud noises.
The spiral is
drawn using the
Scratch pen.
SPIRAL-O-TRON 209
Build the spiral
This project shows you how to use Scratch’s pen to create
fast-moving, interactive effects. Follow the steps below to
build a simple spiral first. You'll need to add the Pen extension
like you did in previous projects.
5 You will now see the “define draw spiral” header in the code
area. Add the following code to it. Read through the Scratch
blocks and think about the steps. Don’t run the project yet
as there isn’t any code to trigger the new block.
pen up
pen down
repeat Repeats
pen up
set TurnAngle to 6
These blocks set
the properties of set StartDirection to 0
our spiral.
set pen size to 5
erase all
draw spiral
SPIRAL-O-TRON 211
Click on “Edit”.
draw spiral
text
Click here for Run without screen refresh Click “OK” to finish.
fast drawing.
Cancel OK
212 MINDBENDERS
10 Now run the project and the spiral will appear so quickly
that you won’t see it happen. The next trick is to keep
redrawing the spiral in different positions so it appears
to spin. Add a new variable called “SpinSpeed”, untick
its box, and change the main code to look like this.
when clicked
set TurnAngle to 6
set StartDirection to 0
set SpinSpeed to 10
set pen size to 5
go to x: 0 y: 0
set DrawLength to 0
change pen color by ColourChange
pen down
repeat Repeats
pen up
214 MINDBENDERS
set TurnAngle to 6
set ColourChange to 3
set Sensitivity to 3
Scratch constantly measures Louder noises make
forever the sound volume and gives thicker spirals.
this block a value from 0 to 100.
erase all
draw spiral
As the volume rises,
the colour flows
change StartDirection by SpinSpeed along the spiral.
▽ Presets ▽ Hiders
If you use your sliders to make a spiral you really You can add code blocks like these to show
like, write down all the values and then create a and hide your sliders when you hit certain
“preset” to set those values at the touch of a key. keys. That way they won’t spoil the view!
set TurnAngle to 4
TRY THIS
Sound reaction
You can have a lot of fun in other
when clicked
projects making sprites react to loudness
Next steps
After working through this book, your knowledge of Scratch should
be strong enough to take you to new places. Here’s some advice
on taking your coding skills to the next level, as well as a few
suggestions on where to find inspiration for your own projects.
Exploring Scratch
The Scratch website www.scratch.mit.edu is a great place to see other
people’s work and share your own projects. Click “Explore” at the top
of the website to view projects that other Scratchers have shared.
There are lots of projects on the
Scratch website. Click here to see
what great stuff you can find.
Use this
menu to sort
Projects Studios projects by
Scratch’s main
All Animations Art Games Music Stories Tutorials Trending categories.
▽ Doodling
Scratch is designed to make experimenting easy. Just when clicked
add a sprite you like and create some fun code blocks
like these. Maybe turn on the pen to see what loopy forever
pattern your sprite makes. Play with variables and
add sliders so you can see their effects immediately. if touching Elephant ? then
when clicked
forever
if a = 2 then
if a == 2:
say Hello!
print("Hello!")
else else:
say Goodbye! print("Goodbye!")
Scratch Python
220 W H AT N E X T ?
Glossary
algorithm call directory graphics
A set of step-by-step To use a function, procedure, A place to store files to Visual elements on a screen
instructions that perform or subprogram. A custom keep them organized. that are not text, such as
a task. Computer programs block in Scratch is a call to pictures, icons, and symbols.
are based on algorithms. the “define” code with the event
same name. Something a computer GUI
animation program can react to, such The GUI, or graphical user
Changing pictures clone as a key being pressed or interface, is the name for
quickly to create the A fully functioning copy the mouse being clicked. the buttons and windows
illusion of movement. of a sprite that can move that make up the part of
and run code blocks on execute the program you can see
backpack its own, separate from See run and interact with.
A storage area in the original sprite.
Scratch that allows export hack
you to copy things code To send something to the An ingenious change to code
between projects. A stack of instruction computer from Scratch, such that makes it do something
blocks under a as a sprite or a whole project new or simplifies it. (Also,
bitmap graphics header block that saved as a computer file. accessing a computer
Computer drawings are run in order. without permission.)
stored as a grid of file
pixels. Compare condition A collection of data stored hardware
with vector graphics. A “true or false” statement with a name. The physical parts of a
used to make a decision computer that you can see
block in a program. See also fractal or touch, such as wires, the
An instruction in Boolean expression. A pattern or shape that keyboard, and the screen.
Scratch that can be looks the same when you
joined to other blocks coordinates zoom in or out, such as the header block
to build code. A pair of numbers that shape of a cloud, a tree, or A Scratch block that starts
pinpoint an exact spot on a cauliflower. a bit of code, such as the
Boolean expression the stage. Usually written “when green flag clicked”
A statement that is either as (x, y). function block. Also known as a
true or false, leading to Code that carries out hat block.
two possible outcomes. costume a specific task, working
Boolean blocks in Scratch The picture a sprite shows like a program within a import
are hexagonal rather on the stage. Rapidly program. Also called a To bring something in from
than rounded. changing a sprite’s procedure, subprogram, outside Scratch, such as a
costume can create or subroutine. picture or sound clip from
branch an animation. the computer’s files.
A point in a program global variable
where two different data A variable that can be index number
options are available, Information, such changed and used by A number given to an
such as the “if then else” as text, symbols, any sprite in a project. item in a list.
block in Scratch. or numbers.
gradient (colour) input
bug debug Moving smoothly from Data that is entered into a
A coding error that makes To look for and one colour to another, computer. Keyboards, mice,
a program behave in an correct errors in like the sky during a and microphones can be
unexpected way. a program. beautiful sunset. used to input data.
GLOSSARY 221
integer operator program sprite
A whole number. An integer A Scratch block A set of instructions that a A picture on the stage in
does not contain a decimal that uses data to computer follows in order to Scratch that code blocks
point and is not written as work something complete a task. can move and change.
a fraction. out, such as checking
interface whether two values are programming language stage
See GUI equal or adding two A language that is used The screen-like area of the
numbers together. to give instructions to Scratch interface in which
library a computer. projects run.
A collection of sprites, output
costumes, or sounds Data that is produced project statement
that can be used in by a computer program Scratch’s name for a program The smallest complete
Scratch programs. and viewed by the user. and all the sprites, sounds, instruction a programming
and backdrops that go language can be broken
list particle effect with it. down into.
A collection of items stored A visual effect in which
in a numbered order. lots of small patterns Python string
move in an organized A popular programming A series of characters. Strings
local variable way to create a larger language created by can contain numbers, letters,
A variable that can be pattern. Particle effects Guido van Rossum. Python or symbols.
changed by only one in Scratch usually is a great language to learn
sprite. Each copy or use clones. after Scratch. subprogram or subroutine
clone of a sprite has Code that carries out a specific
its own separate version physics random task, working like a program
of the variable. The science of how A function in a within a program. Also called
things move and affect computer program that a function or procedure.
loop each other. Including allows unpredictable
A part of a program that physics is often important outcomes. Useful when turbo mode
repeats itself, removing in simulations and games – creating games. A way of running Scratch
the need to type out the for example, to create projects that makes the
same piece of code realistic gravity. run code work much faster than
multiple times. The command to make normal. You can switch turbo
pixel art a program start. mode on and off by holding
memory A drawing made the shift key as you click the
A computer chip inside a of giant pixels or Scratcher green flag.
computer that stores data. blocks, mimicking Someone who uses Scratch.
the appearance of tweak
message graphics in early server A small change made to
computer games. A computer that stores files something to make it work
A way to send information
accessible via a network. better or differently.
between sprites.
pixels
The coloured dots variable
network simulation
on a screen that A place to store data that can
A group of interconnected A realistic imitation of
make up graphics. change in a program, such as
computers that exchange something. A weather
the player’s score. A variable
data. The internet is a simulator might re-create
procedure has a name and a value.
giant network. the action of wind, rain,
Code that carries out a and snow.
specific task, working vector graphics
operating system (OS) Computer drawings stored
like a program within software
The program that controls as collections of shapes,
a program. Also called a Programs that run on
everything on a computer, making them easier to
function, subprogram, or a computer and control
such as Windows, macOS, change. Compare with
subroutine. how it works.
or Linux. bitmap graphics.
222 W H AT N E X T ?
Index
centre tool 73, 76, 89, 131, 146, 156, “Convert to Vector” 158 Font menu 85
158, 202 coordinates 74, 83, 87, 89, 105, 118, “For this sprite only” variable 159
chance 60 131, 220 “forever” block 17, 29, 33, 129
“change color effect” block 26, copies of projects 57, 93 “forever” loops 42, 46, 67, 78, 137,
Page numbers in bold refer 30, 196 costume editor 118 179, 196, 212, 213
to main entries. “change pen color” block 101, costumes 220 fortune-telling project 60
103, 213 centring 146, 158 Fractal Trees 23, 162–71, 172, 174
“change size” block 92 changing 37, 43, 78, 132 fractals 162, 220
“change whirl effect” block 92 checking size 201–02 in nature 163
A
addition 108
Christmas cards 153
circle tool 75, 145, 187, 201
creating 187, 201–02
library 75
framing 79
full-screen mode 20, 31, 69, 82,
afterimages 200 “clear” block 31, 101, 110, 114 modifying 187 103, 166, 177, 212
algorithms 15, 44, 164, 220 “clear graphic effects” block 33 naming 202 function 220
“and” block 55, 150 clones 77, 220 Costumes tab 21, 37, 118, 136, 164 Funny Faces 70–79
Animal Race 22, 48–59 adding movement to 96 countdowns 57, 138, 141
animations 182, 184, 188, 220 creating symmetrical patterns cursor tools 20
G
arrow keys 32, 42, 43, 104, 197 with 175 custom blocks 106–19, 191, 209
art projects 13, 22, 80–119 deleting 97, 99, 101, 148, 149, 170
Birthday Card 22, 82–93 drums 195–96 games consoles 15
Fantastic Flowers 22, 106–19
Spiralizer 22, 94–105
Firework Display 154–61
Fractal Trees 163–66 D games projects 13, 15, 120–41
Tunnel of Doom 22, 122–33, 140
Ask Gobo 22, 60–69 hiding 104 data 220 Window Cleaner 22, 134–41
atmosphere 124–25 maximum number 96, 149, 154, debug 220 ghost effect 33, 78, 92, 134, 139,
169, 179 “define” blocks 211 151, 159
Snowflake Simulator 175–77 “define” header block 110, 111, 112, “glide” block 83
special code affecting 96 113, 116, 119 global variables 220
B Spiralizer 94–97
stamping a copy 149
degrees, and direction 89
dice 64
Gobo 60–69
“go to” blocks 76, 105, 127, 131
backdrop 17
adding a message to 84–85 unique identification number difficulty “go to front layer” block 153
changing colour 167 195, 196, 202, 203–04 making games harder 58 “go to mouse-pointer” block 28,
library 39, 51, 119, 152, 183 Virtual Snow 144, 145, 147–49 slider 141 127
loading a new 39, 51, 62, 86 Window Cleaner 134, 136–39 Dino Dance Party 17, 22, 34–47, gradient tool 147, 157
backpack 19, 21, 220 clubs, coding 8, 219 164 graphics 13, 220
Birthday Card 22, 82–93 code 15, 16, 221 directions 89 “greater than” block 66
bitmap graphics 220 building 16, 28–29 directory 220 green flag 17, 29
“Bitmap Mode” 72 changing 30 division 108 grow tool 202
blocks 16, 220 running 29 Drumtastic 23, 190–97 GUI (graphical user interface)
actions performed by 17 timing of 83 10–11, 221
custom 106–19 triggering (“calling”) 109, 110
ready-made 15, 16 working together 17
Eedit custom block
H
running faster 211 code area 20, 21, 28
blocks palette 20, 21, 28–30, 159 Code tab 21, 38, 89, 147, 203
bookmarking projects 218 coding 111–13 hack 220
Boole, George 66 clubs 8, 219 editing sounds 189 hacks and tweaks
Boolean conditions 66 parties 219 editor mode 96 Animal Race 57–58
Boolean expressions 220 what is coding? 10–23 “equal to” block 66 Ask Gobo 67–69
Boolean operator: “not” 55 colour eraser tool 122, 125, 126, 187 Birthday Card 92–93
boxes, drawing 85, 146, 156 blending 146 Events blocks 29, 31 Cat Art 32–33
broadcast blocks 91, 160 changing 26, 30–31, 32, 78, explosions 154, 158–59 Dino Dance Party 46–47
“broadcast message” block 54 160–61, 207 export 220 Drumtastic 197
“broadcast and wait” block 165 gradient 147, 157, 220 Fantastic Flowers 118
brush tool 72, 73, 75, 135, 146, 156 optical illusion 200–07 Firework Display 160–61
bugs 15, 220
see also hacks and tweaks
colour palette 72, 73, 77, 125, 146,
201 Ffaces, creating your own 70–79 Fractal Trees 168–69
Funny Faces 78
conditions 66, 220 The Magic Spot 207
Control blocks 29 “Fairydust” 183 Snowflake Simulator 178–79
Fantastic Flowers 22, 106–19
C
control key 19 Spiral-o-tron 215
controls “favourite” 219 Spiralizer 103–05
C programming language 14 camera 134, 139–40 File menu 36 Sprites and Sounds 188–89
C++ programming language 14 keyboard 42, 188 files 220 Tunnel of Doom 132–33
calculations 108 making games harder 58 fill tool 73, 77, 79, 97, 125, 136, 147, Virtual Snow 153
call 109, 110, 220 mouse 19, 28–29, 122, 127–30, 174, 191, 203, 209 Window Cleaner 140–41
camera control 139–40 134, 138, 154, 156, 157 Firework Display 23, 154–61 hand movement, controlling by
Cat Art 22, 26–33 touchscreen 182 fisheye effect 33 134
INDEX 223
hardware 220
header blocks 220
repeat until 128
and repeating patterns 162, NO Dino Dance Party 34–47
Drumtastic 190–97
“hide” block 151 164, 168, 176, 178 names, player’s 50, 51 Fantastic Flowers 22, 106–19
“Hip-Hop” dance postures 47 and sprite movement 38 networks 221 Firework Display 154–61
hypnotic effect 212 “loudness” block 215 “New message” block 54 Fractal Trees 162–71
“love” 218, 219 “next costume” block 37, 38 Funny Faces 22, 70–9
“not” block 55 The Magic Spot 200–07
L mouse-pointer
moving sprites 26, 104
“pick random” blocks 64, 68, 113,
115, 117, 132, 150, 168, 177
Snowflake Simulator 176,
178
laptops 15 right-clicking 19 pixel art 221 Spiral-o-tron 210
“length” block 116 “move” block 96, 98 pixels 221 repeat until loops 128
“less than” block 66 movement “play sound until done” block 125, rotation styles 41, 46
libraries 221 and costume change 37–39, 184 “Run without screen refresh” 211
backdrop 39, 51, 119, 43–5 “point in direction” block 42, 210 running programs 29
152, 183 moving patterns 154 programming see coding
costumes 75 multicoloured effect 32 programming languages 13,
sounds 40, 57, 86, 124, 130, 14–15, 219, 221
141, 184–87, 188
sprite 36, 75, 96, 188, 195
multiplayer games 141
multiplication 108 see also Java; Python; Scratch
programs 221
Ssaving work 31, 93, 115, 132, 141, 151
music 13
line tool 75, 156, 202 adding 40, 124–25 algorithms 44 online and offline Scratch 18
Linux computers 18 Drumtastic 190–91 Boolean conditions 66 “say” block 47, 51, 64, 68–69, 192
lists 221 Happy Birthday 86, 87, Boolean operators 55 scale 119
local variables 221 90–91, 93 building 16 scores 50, 51, 137, 140
Looks blocks 30 recording your own 93, 214 loops 33 Scratch 13, 15
loops 29, 33, 119, 219, 221 singing animals 197 making choices 43, 60 downloading and installing 18
and clones 77, 96, 105, 152 Spiral-o-tron 208, 214 running 17, 29 exploring 218
countdown 139, 141 stopping 130 subprograms 106, 110 getting Scratch 3.0 18–19
forever 42, 46, 67, 78, 137, 179, tempo 197 writing 12 how Scratch works 16–17
196, 212, 213 music and sound projects 23, project page 218 online and offline Scratch 18
loops inside loops 45 180–97 projects 221 Scratch 2.0 19
music 40 Drumtastic 23, 190–97 Animal Race 22, 48–59 Scratch interface 20–21
repeat 44–45, 46, 92, 108, Sprites and Sounds 23, Ask Gobo 22, 60–69 a typical Scratch project 17
112, 159, 168, 192, 194, 182–89 Birthday Card 22, 82–93 versions of 19
196, 210 Cat Art 22, 26–33 website 218
224 W H AT N E X T ?
Scratch pen 94, 95, 100–02, 162, Spiral-o-tron 23, 208–15 “stop” block 59 global 220
208–09, 219 Spiralizer 22, 94–105 strings 192, 221 for individual clones 97–99, 159,
Scratchers 221 sprites 16, 221 Studios tab 218 195, 200, 203
secret pictures 144, 151–52 adding accessories to 75 subprograms 106, 110, 221 local 221
“See inside” 218 adding code 136, 137 subtraction 108 The Magic Spot 207
select tool 85, 88, 156 adding more 51–53, 57, 132 subtraction block 119 playing with 219
Sensing blocks 42 adding movement 16, 41 supercomputers 15 position 59
servers 221 adding sounds 182–89 symmetry and random numbers 63, 64
“Share” button 219 adding speech 47 six-fold 172, 173 sliders to alter value of 94,
sharing projects 218, 219 built-in sounds 184 values 175 97–99, 102
shift key 19, 131, 145, 151 centre point 73, 76, 131 Snowflake Simulator 174
shortcuts, keyboard 103 changing colour 16, 67 Spiral-o-tron 209, 212, 213, 214
shrink tool 202
simulations 23, 142–79, 221
changing costumes 36, 37, 67
changing size 32, 62, 92, 119, Ttabs 20, 21 Window Cleaner 136
Variables blocks 50, 59, 63, 65, 97,
Firework Display 23, 154–61 127, 128, 129, 130 131, 136, 159, 164, 174, 191
Fractal Trees 23, 162–71, 172, 174 copying 39 templates 118 vector graphics 158, 221
Snowflake Simulator 23, 172–79 creating your own 16, 70–79, 88, tempo 197 vertical gradient 147, 157
Virtual Snow 23, 144–53 151, 156, 188 text tool 85 Virtual Snow 23, 144–53
singing animals 197 dancing 34–47 thought bubbles 59 volume 214, 215
six-fold symmetry 172, 173 delivering messages 16 touchscreen computers 182
sliders invisible 151–52 trees
W
difficulty 141 mouse control 122–23, 127–30 fractal 162–71
hiding 104, 215 painting new 135–36 true/false statements 55, 66
playing with 219 painting with 26–33 Tunnel of Doom 22, 122–33, 140 “wait” blocks 38, 152, 179
and value of variables 94, 97–99, renaming 52, 74, 76, 88, 124, 127, turbo mode 151, 152, 221 “wait until” blocks 55, 196
102, 103, 215 145, 164 “turn” blocks 78, 89, 98, 112, 166, web browsers 14, 18
Snowflake Simulator 23, 172–79 selecting new 36, 62 196 webcams 134, 139–40
software 18–19, 221 setting direction of 99 “turn 180 degrees” block 46 websites 15
sound 13, 180–97 sprites library 36, 75, 96, 188, tweaks Scratch 18, 218
adding 93, 124, 141, 214 195 see hacks and tweaks “when green flag clicked” block 29
Drumtastic 190–97 sprites list 20 two-player games, Animal Race 48 “when I receive” block 165, 166,
editing 189 using photos to make 93 170, 177, 196
previewing 124 see also clones “when space key pressed” block
recording your own 188, 189, 214
library 40, 57, 86, 124,
Sprites and Sounds 23, 182–89
stage 17, 20, 221 UV 31, 197
Window Cleaner 22, 134–41
130, 141, 184–87, 188 centre of 74 undo 126 Windows operating system 14, 18
Spiral-o-tron 208, 214 clearing 31, 33, 99, 110, 115, 179 unpredictability 60, 64 word processors 14
Sprites and Sounds 182–89 decorating 51 upload 93
tempo 197 flashing 156 variables 51, 221
volume 214, 215
Sound blocks 184
position on 74
code blocks 40
Animal Race 48, 50, 51
Ask Gobo 60, 63, 64, 65, 66 XYZ
sound effects 57, 67, 105, 132, 189 see also backdrop countdown 138 x coordinates 74
Sounds tab 21, 40, 57, 124, 183, “stamp” block 26, 30, 31, 77, 106, difficulty 139, 140, 141 y coordinates 74
184, 188 108, 149–50, 170 Drumtastic 191, 193, 195 yes/no questions
special effects 13, 26, 33, 67, 78, starfield 153 experimenting with 168–69 Boolean operators 55
92, 153 “start sound” block 57, 130, 184 Fantastic Flowers 119 if then else 206
speech bubbles 61, 191 statements 221 Fractal Trees 164–65 zoom 21, 158
Acknowledgements
Dorling Kindersley would like to thank Caroline Hunt and Steph Lewis for The publisher would like to thank the following for their kind
proofreading; Helen Peters for the index; Sean Ross for help with Scratch; permission to reproduce their photographs:
Ira Pundeer for editorial assistance; Nishwan Rasool for picture research
assistance; Abhijit Dutta, Priyanka Sharma, and Mark Silas for code testing; (Key: a-above; b-below/bottom; c-centre; f-far; l-left; r-right; t-top)
and Vishal Bhatia for pre-production assistance.
134 123RF.com: Jacek Chabraszewski (b); Dreamstime.com: Pavel Losevsky
Jon Woodcock would like to thank all his code clubbers over the years for (b/background); 163 Corbis: Trizeps Photography / photocuisine (cra); NASA:
teaching him how to think in Scratch; and Matty and Amy for all their questions. (cr); Science Photo Library: SUSUMU NISHINAGA (crb); 173 NOAA: (tr)
Scratch is developed by the Lifelong Kindergarten Group at MIT All other images © Dorling Kindersley
Media Lab. See http://scratch.mit.edu For further information see: www.dkimages.com