Coding Games in Scratch
Coding Games in Scratch
I N S C R A T C H
F O R K I D S
Due to the complex integration of images
G a m
I N S C R A T C H
F O R K I D S
OJNWOODCOCK
DK UK DK INDIA
Producers, p r e - p r o d u c t i o n F r ancescW
a a rdell Managing art editor
A s s o c i a t e p u b l i s h i n g d i r e c to r L i z Wheeler
A r t d i r e c tor K a r en Self
Firs t p u b l i s h e d i n G r e a t B r i t a i n i n 2 0 1 5 b y
D o r l i n g K i ndersley Limited
D K , O n e E m b a s s y G a r d e n s , 8V i a d u c t G a r d e n s , Lo n d o n , S W 1 1 7 B W
D o r l i n g K i n d e rsley Ve r l a g G m b H . A r n u l f s .t r1 2 4 , 8 0 6 3 6 M u n i c h , G e r m a n y
10 9 8 7 6 5 4 3 2 1
001–339453–J u n e / 2 0 2 4
A l l r i g h t s r e s e r ve d.
N o p a r t o f t h i s p u b l i c a t i o n m a y b e r e p ro d u c e d , s t o r e d i n o r i n t r o d u c e d i n t o a r e t r i e v a l
s y s t e m , o r t r a n s m i t t e d , i n a n y f o r m , o r b y a n y m e a n s ( e l e c t ro n i c , m e c h a n i c a l, p h o t o c o p y i n g,
r e c o r d i n g , o r o t h e r w i s e ) , w i t h o u t t h e p r i o r w r i t t e n p e r m i s s i o n o f t h e c o p y r i g h t o w n e. r
A C I P c a t a l o g u e r e c o r d f o r t h i s b o o k i s a v a i l a b l e f r o m t h e B r i t i s h L i b r a r .y
ISBN: 978-0-2416-5891-8
Printed a n d b o u n d i n C h i n a
w w w .d k . c o m
tshetkirhom
wbTsFedai
pihsdeirwfae™itlSrecCoiunc
snpl’DieKrtm
pealn–so
[Link]
nraetam
Lro
yst/irnolfnbina/iakutmaus
m
o/[Link].
C A R O L V O R D E R M A N M A ( C A NA TB ) , M B E ,
i s o n e o f B r i t a si ’n b e s t - l o v e dT V p r e s e n t e r s a n d
i s r e n o w n e d f o r h e r m a t h e m a t i c a l s k i l l s . S h e h a s h o s t e d n u m e r o u sT V s h o w s o n s c i e n c e a n d
2 6 y e a r s . A C a m b r i d g e U n i v e r s i t y e n g i n e e r i n g g ra d u a t e , s h e h a s a p a s s i o n f o r c o m m u n i c a t i n g
s c i e n c e a n d t e c h n o l o g, y a n d h a s a k e e n i n t e r e s t i n c o d i n g .
DRJONWOODCOCKMA
ON
OX
has a degree in physics from the University of Oxford and
a PhD in computational astrophysics from the University of London. He started coding at the
age of eight and has programmed all kinds of computers, from single- chip microcontrollers
in high-tech companies, and intelligent robots made from junk. Jon has a passion for science
and technology education, giving talks on space and running computer programming clubs
in schools. He has worked on numerous science and technology books as a contributor and
consultant, includings DK’ Computer Coding for Kids and Computer Coding Made Easy
CRAIG STEELE
i s a s p e c i a l i s t i n C o m p u t i n g S c i e n c e e d u c a t i o n w h o h e l p s p e o p l e d e ve l o p
d i g i t a l s k i l l s i n a f u n a n d c r e a t i ve e n v i r o n m e n t . H e i s a f o u n d e r o f Co d e r D o j o i n S c o t l a n d ,
w h i c h r u n s f r e e c o d i n g c l u b s f o r y o u n g p e o p l e . C ra i g h a s r u n d i g i t a l w o r k s h o p s w i t h t h e
R a s p b e r r y Pi Fo u n d a t i o n , G l a s g o w S c i e n c e C e n t r e , G l a s g o w S c h o o l o f A r t , B AAF, T a n d
t h e B B C m i c r o : b i t p r o j e c t . C r asi gf’ i r s t c o m p u t e r w a s a Z X S p e c t r u m .
14
Atmosphere
16
yTp e s o f g a m e
18
G E T T I N G S TA R T E D
22
I n t r o d u c i n g S c r a tch
24
G etting Scratch
26
S cratch tour
STAR H U N T E R
30
Score 0
D O G ’ S D I N N E R
132 H o w t o b u i l d D os gD’ i n n e r
G L A C I E R R A C E
Laura Gems: 13
t e e n a g e S t e v e J o b s a n d h i s f r i e n d S t e v e Wo z n i a k , w h o l a t e r f o u n d e d A p p l e
t o g e t h e r, c r e a t e d t h e a r c a d e g a m e B r e a k o u t .
T h e y s t a r t e d c o d i n g s i m p l y b e c a u s e t h e y e n j o y e d i t . T h e y h a d n o i d e a h o w f a r
i t w o u l d t a k e t h e m o r t h a t t h e c o m p a n i e s t h e y w e r e t o b u i l d w o u l d c h a n g e
t h e w o r l d . Yo u m i g h t b e t h e n e x t o n e l i k e t h e m . C o d i n g d o e s n ’ t h a v e t o
b e c o m e a c a r e e r, b u t i t ’s a n a m a z i n g s k i l l a n d c a n u n l o c k e x c i t i n g d o o r s t o
y o u r f u t u r e . O r y o u m i g h t j u s t w a n t t o p l a y a r o u n d w i t h c o d e f o r t h e f u n o f i t .
C o m p u t e r g a m e s o p e n u p w o r l d s o f i m a g i n a t i o n . T h e y r e a c h o u t a c r o s s
t h e i n t e r n e t a n d a l l o w u s t o p l a y t o g e t h e r. T h e y a r e p a c k e d w i t h c r e a t i v i t y,
f r o m m u s i c , s t o r i e s , a n d a r t t o i n g e n i o u s c o d i n g . A n d w e ’r e h o o k e d o n
t h e m : s o m u c h s o t h a t t h e g a m e s i n d u s t r y i s n o w w o r t h m o r e t h a n t h e
m o v i e i n d u s t r y. I t ’s h u g e .
a n d t h e l a n d s c a p e s.
B u t f i r s t y o u n e e d t o t a k e c o n t r o l o f y o u r c o m p u t e r. To t e l l a c o m p u t e r w h a t
t o d o , y o u n e e d t o s p e a k i t s l a n g u a g e a n d b e c o m e a p r o g r a m m e r ! T h a n k s t o
l a n g u a g e s l i k e S c r a t c h™ , i t ’s n e v e r b e e n e a s i e r. J u s t f o l l o w t h e s i m p l e s t e p s
i n t h i s b o o k t o b u i l d e a c h g a m e a n d y o u ’ l l s e e w h a t g o e s o n i n s i d e e a c h o n e .
F o l l o w t h e c h a p t e r s i n o r d e r, a n d y o u ’ l l p i c k u p t h e e s s e n t i a l s k i l l s y o u n e e d
t o d e s i g n a n d b u i l d y o u r v e r y o w n g a m e s .
C A R O LV O R D E R M A N
C o m p u t e r
g a m e s
a b o u t a l l t h e i n g r e d i e n t s t h a t m a ke u p
t h e g a m e a n d h o w t h e y m i x t o g e t h .e r
Characters
I n m o s t g a m e s , t h e p l a ye r u s e s a n o n - s c r e e n
c h a r a c t e r t o e n t e r t h e g a m e w o r l d . I t co u l d
a n a n i m a l , a p r i n c e s s , a r a c e c,a ro r e v e n j u s t
a s i m p l e b u b b l eoT. c r e a t e a s e n s e o f d a n g e r
h a v e e n e m y c h a r a c t e r s t h a t t h e p l a ye r h a s
t o d e f e a t o r e s c a p e f ro m .
T h e s e a r e t“ hvee ribns
such as running
objects, casting
The mechanics a
well-designed m
Objects
Nearly all games include objects, from stars and coins that
b o o s t h e a l t h o r s c o r e s t o k e ys t h a t u n l o c k d o o r s . N o t a l l
o b j e c t s a r e g o o d – s o m e g e t i n t h e p l a ye s r way,’ s a p t h e i r
h e a l t h , o r s t e a l t h e i r t r e a s u r e s . O b j e c t s c a n a l s o w o rk
t o g e t h e r t o c r e a te p u z z l e s f o r t h e p l ay e r t o s o l v e.
E v e r y game challenges the player to achieve some
k i n d o f g o a l , w h e t h e r ist w’ i n n i n g a r a c e , c o n q u e r i n g
a n e n e m, y b e a t i n g a h i g h s c o r e , o r s i m p l y s u r v i v i n g
g o a l s , s u c h a s u n l o c k i n g d o o r s t o n e w l e ve l s o r
Controls
K e y b o a r d s , m i c e, j o y s t i c k s,
Difficulty level
o f t h e i r c h a r a c t ,e rs o t h e
A gam
s en’ o f u n i f si tt ’o o e a s y o r h a r d . M a n y g a m e s
m a k e t h e c h a l l e n g e s e a s y a t t h e s t a r t, w h i l e t h e
p l a y e r i s l e a r n i n g, a n d m o r e d i f f i c u l t l a t e r a s t h e i r
s h o u l d r e s p o n d i n s t a n t l. y
s k i l l s i m p r o ve . G e t t i n g t h e d i f f i c u l t y l e v e l j u s t r i g h t
G A M E D E S I G N
Playabili t y
G a m e s d o n ’t h a v e t o b e c o m p l i c a t e d t o m a k e
p e o p l e w a n t t o p l a y t h e m o ve r a n d o v e r a g a i n .
w a s a s i m p l e t e n n i s s i m u l a t o r c a l l e d [Link]
b a l l w a s a w h i t e s q u a r e a n d t h e r a cquets were
w h i t e l i n e s t h a t c o u l d o n l y m o ve u p a n d d o w n .
A l t h o u g h t h e r e w e re n o f a n c y g r a p h i c s, p e o p l e
loved Po n g b e c a u s e i t h a d g r e a t p l a yability. Th ey
c o u l d c o m p e t e a g a i n s t f r i e n d s, j u s t l i k e i n r e a l
t e n n i s , a n d i t w a s j u s t h a rd e n o u g h t o d e m a n d
l e a v i n g p l a y e r s a l wa y s w a n t i n g a n o t h e r g a m e.
◁
l eT l i n g s t o r i e s
a g a m e a n d g i v e s m e a n i n g t o t h e p l ay es r ’
a c t i o n s . B l o c k b u s t e r g a m e s h a v e m ov i e - l i k e
m a k e s p l a y e r s f e e l l i k e t h e y ’ re o n a m i s s i o n .
Sound
f e e l e x c i t i n g , s c a r, y o r e v e n s i l l, y
The speed of
s p e l l c a n c a u s e a j o l t o f t e r r .o r
changes the
excitement a
e f f e c t s t o m a k e p l ay e r s f e e l l i k e
I s t e’ a s y t o s t
t h e y ’ re i n s i d e t h e a c t i o n .
when you ca
think about
next, but wi
clock and fa
you can’t h e l p
under pressu
Colour scheme
uoY c a n c h a n g e t h e a t m o s p h e r e i n a g a m e
s i m p l y b y a l t e r i n g t h e c o l o u r s. B r i g h t b l u e ,
yellow, a n d g r e e n f e e l s w a r m a n d s u n n, y for
i n s t a n c e , w h i l e i c y b l u e s a n d w h i te f e e l w i n t r, y
a n d d a r k e r c o l o u r s m a k e a g a m e f e e l s p o o k. y
movements and adjust
a l l o w i n g t h e p l a y e r to
t h e r e a l w o r l d. A s a r e s u l t,
Whereareyou?
O n e o f t h e e a s i e s t w a y s t o c reate
a t m o s p h e r e i s t o g i ve a g a m e a l o c a t i o n
b y a d d i n g a b a c k g r o u n d i m a [Link] a k e
game’
s c h a r a c t e r s m a t c h t h e s e t t i n g – d o n’t
o u t e r s p a c e , fo r i n s t a n c e .
△ △
A d a r k f o r e s t i s t h e p e r fe c t s e t t i n g A s u n n y b e a c h c r e at e s a c a r n i v a l
a n o p p o n e n t t o p l a, y a
y o u t o a g a m e o f c a r d s,
Racing
p l a y se rv’i e w p o i n ot . Ts u c c e e d , y o u n e e d
t o l e a r n e a c h r a c e t r a c k i n s i d e o u t s o you
△ △
Sandbox Combat
S o m e g a m e s f o r ce p l a y e r s a l o n g a s e t p a t h , b u t N i m b l e f i n g e r wo r k i s v i t a l f o r g a m e s i n v o l v i n g c l o s e -
complete freedom to ex p l o r e t h e g a m e w o r l d a t and how to use many d ifferent attac k and defence
y o u r o w n p a c e a n d c h o o s e d i f fe r e n t q u e s t s w i t h i n i t . m o v e s , f r o m s l a m s a n d s o m e r s a u l t s t o s p e c i a l p o w e r s.
△
Simulator
I f y o u w a n t a p u p p y b u t d o n ’t w a n t t h e b o t h e r o f f e e d i n g
a n d w a l k i n g i t , a v i r t u a l p e t m i g h t s u i t y o u . S i m u l at o r s a i m
t o r e - c r e a t e re a l - l i f e s i t u a t i o n s . S o m e a r e m o r e t h a n j u s t a
p r o f e s s i o n a l p i l o t s u s e t h e m f o r t r a i n i n g.
Puzzle
Sport
P l a y t h e g a m e o f y o u r c h o i ce a s y o u r f a vo u r i t e t e a m , s e t i n p u z z l e sT. h e r e a r e m a n y d i f f e r e n t t y p e s , f r o m
Planning a game
Score 10
I m a g i n e y o u w a n t to c r e a t e a g a m e
i n w h i c h y o u f l y a p a r r o t ov e r a r i v e, r
c o l l e c t i n g a p p l e s a s t h e y d r i f t downstream
b u t a v o i d i n g a n a n g r y lion.o uY w o u l d
T h e a p p l e d r i f t s d o w n s t r e am
o v e r a n d o v. e r It reappears on
▽
Apple
J u m p t o t h e l e f t e d g e o f t h e s c r e e n .
R e p e a t t h e f o l l o w i n g s t e p s o v e r a n d o v e r a g a i n :
M o v e a b i t t o t h e r i g h t .
complicated task into a set of very
s i m p l e s t e p s a s s h o w n h e r e.
I f I g e t t o t h e r i g h t e d g e o f t h e s c r e e n t h e n
j u m p b a c k t o t h e l e f t e d g e .
I f I t o u c h t h e p a r r o t t h e n
a d d o n e t o t h e p a r r o t ’s s c o r e a n d
j u m p b a c k t o t h e l e f t e d g e .
m o v e a b i t t o t h e l e f t i f I c a n .
I f t h e p l a y e r p r e s s e s t h e r i g h t a r r o w t h e n
m o v e a b i t t o t h e r i g h t i f I c a n .
I f t h e p l a y e r p r e s s e s t h e s p a c e b a r t h e n
m o v e a l l t h e w a y t o t h e b o t t o m o f t h e s c r e e n t a k i n g a s e c o n d a n d
m o v e a l l t h e w a y b a c k t o t h e t o p t a k i n g a s e c o n d
▷ Lion
T h e l i o n i s t h e p l a y e sr e’ n e m y a n d c a n
Programming languages
I t i s c o n t r o l l e d by a s i m p l e p r o g r a m .
E n g l i s h , b u t i f y o u w a n t e d to c r e a t e t h e g a m e
o n a c o m p u t e, ry o u w o u l d n e e d t o t ra n s l a t e
J u m p t o t h e m i d d l e o f t h e s c r e e n .
c a n u n d e r s t a n d : a p r o g r a m m i n g l a n g u a g e.
R e p e a t t h e s e s t e p s i n t u r n :
W r i t i n g p r o gr a m s w i t h a p r o g r a m m i n g
l a n g u a g e i s c a l l e d c o d i n g o r p r o g ramming.
I f t h e p a r r o t i s t o m y l e f t t h e n
m o v e a b i t t o m y l e f t .
c o d i n g a n d g r e a t fo r m a k i n g g a m e s .
I f t h e p a r r o t i s t o m y r i g h t t h e n
m o v e a b i t t o m y r i g h t .
I f t h e p a r r o t t o u c h e s m e t h e n
s t o p t h e g a m e .
G e t t i n g
s t a r t e d
o b j e c t s , o r s p r i t e s, w i l l a p p e a r i n t h e g a m e . S c r a t c h h a s
a l a r g e l i b r a r y o f r e a d y - m a d e s p r i t e s to g e t y o u s t a r ted.
called code.
appears whenever
y o u s t a r t a new
move 20 steps
S c r a t c h p r o j e c t.
say Hello!
Worki n g t o g e t h e r
G a m e s a r e u s u a l l y m a d e u p o f s e v e ra l s p r i t e s w o r k i ng
Experimenting
t o g e t h ,e re a c h c o n t r o l l e d b y t h e i r o w n c o d e . Co d e
b l o c k s m a k e s p r i t e s m o v e a b o u t , c r a s h i n t o e a c h o t h ,e r
you’ve b u i l t a g a m e , si t e’ a
to it or change how it w
w i t h t h e c o doeY. u c a n s e
enemies to make a
HELP!
c o d e b l o c k s t h a t y o u’ve
built.
o Tm a k e t h e s t a g e
Background image
p l a y se rc ’a t s p r i t e .
I n a t y p i c a l g a m e , t h e p l a ye r m o v e s o n e s p r i t e
a u t o m a t i c a l l y . Th e c o d e b e l o w m a k e s t h e
when clicked
forever
“Tf ho er e ve r ”
block keeps
the sprite
move 15 steps
moving
endlessly.
Online Scratch
w i n d o w w i t h o u t d o w n l o a d i n g a n y thing.
uoY w i l l n e e d t o s e t u p a S c r a t c h a cc o u n t .
J o i n S c r a t c h Sign in
1 2
[Link]
g a m e s w i l l s t a y p r i v a t e u n l e s s yo u c l, i“ wcShare”
kh i c h w i l l screen to start a new project. If you use the online version
publish them on the web. of Scratch, you can access your projects from any computer
.
Offline Scratch
uoY c a n a l s o d o w n l o a d t h e S c r a t c h
i t o f f l i n e Thi
. s i s p a r ticularly useful if your
L a u n c h S c r a t c h
I n s t a l l S c ra t c h
2
1
[Link]/
For t h e o f f l i n e v e r s i o n o f S c r a tc h , g o t o
download
. Fol l o w t h e i n s t r u c t i o n s o n s c r e e n t o d o w n l o a d
o p e n , r e a d y f o r yo u t o
t h e i n s t a l l a t i o n f i l e s , t h e n d o u b l e - c l i c k t h e m . A f ter
b e g i n p r o g r a m m i n g.
i n s t a l l a t i o n , a S c r a t c h i c o n w i l l a p p e a r o n y o u r d e s k t o p.
There’
s no need to
c r e a t e a u s e r a c c o unt
version of Scratch.
on Wi n d o w s a n d M a c c o m p u t e r s . I f yo u r
version instead.
Vers i o n 2 . 0
Old and
I n o l d e r v e r s i o n s o f S c r a tc h , s u c h a s
new versions
▾ ▾
S c r a t c h 3 . 0 , t h e l a t e st
Scripts
Untitled
by abcd (unshared)
Motion
Looks
Sound
w r i t i n g T. h e p ro j e c t s
Pen
Data
move 10 steps
turn 15 degrees
versions of Scratch,
point in direction 90
so make sure
▾
point towards
Sprites
Costumes
Sounds
Code
Stage
Cat
1 backdrop
New backdrop:
Motion
Motion
move 10 steps
Looks
turn 15 degrees
▷
turn 15 degrees
Vers i o n 3 . 0 Sound
Events
go to random position
T h i s v e r s i o n o f S c r at c h w a s r e l e a s e d i n
go to x: 0 y: 0
Control
2 0 1 9 . I t s f e a t u re s i n c l u d e “aEnx t e n s i o n ”
Sensing
s e c t i o n c o n t a i n i n g n e w p r o g ra m m i n g
glide 1 secs to x: 0 y: 0
Operators
point in direction 90
Variables
a m o r e s o p h i s t i c a t e d s o u n d e d i t .o r An
point towards m o u s e -pointer
My Blocks
o p t i o n t o u s e h i g h - c o n t r a s t b l o c k co l o u r s
Backpack
Looks
turn 15 degrees
turn 15 degrees
Sound
t o r e v e a l d i f ferent
sets of blocks.
Events
go to random position
go to x: 0 y: 0
Control
Sensing
glide 1 secs to x: 0 y: 0
Operators
S T A G E A R E A
B L O C K S C O D E
point in direction 90
Vari a b l e s
P A L E T T E A R E A
S P R I T E S
My Blocks
L I S T
B A C K P A C K S T A G E I N F O
Scratch window
Blocks palette
l e f t o f t h e S c r a t c h w i n d o. w
selected
S E T L A U N C H S P E E D W I T H T H E S L I D E R
P R E S S T H E L A U N C H E R T O F I R E
These code
Launcher sprite.
when clicked
set LaunchSpeed to 10
go to x: –200 y: –140
go to front laye r
forever
Blocks snap
together – use
x
Sprite Launcher
finger if using a
tablet to move
them around.
Zoom in on
the code
p r o j e c t a p p e a r h e r e. Whe n
y o u s e l e c t a s p r i t e, i t s c o d e
A I M O F T H E G A M E
c a t t o c o l l e c t t h e s t a r s, b u t w a t c h o u t for
d e a d l y o c t o p u s e suoY.’ l l n e e d t o move
q u i c k l y t o s u c c e e [Link] e m a i n s p r i t e s
i n t h e g a m e a r e s h o w n b e l o w.
Cat
s c r e e n w i t h y o u r c o m p u ter
m o u s e o r y o u r f i n g e r i f y o ure’
using a tablet.
Octopuses
is t g’ a m e o v e r !
Stars
i n r a n d o m p l a c e usoT. c h a s t a r
to score a point.
Use your computer mouse or
y o u r f i n g e r i f y o ur’e u s i n g a
Motion
Motion
move 10 steps
turn 15 degrees
buttons here
Events
go to random position
r e v e a l s d i f fe r e n t
go to x: 0 y: 0
Control
sets of blocks.
Sensing
glide 1 secs to x: 0 y: 0
Operators
point in direction 90
Variables
Sprite S prite1
My Blocks
Show
Choose blocks
Sprite1
Backpack
on the left.
We’l l p r o g r a m t h e c a t t o m o v e w h e r e ve r t h e p l a y e r
m o v e s i t t o – u s i n g t h e m o u s e o n a co m p u t e r o r
t h e p l a y se rf ’i n g e r o n a t a b l e t . S e l e c tg t“h e o t o
r a n d o m p o s i t i ob nl o” c k a n d d r a g i t t o t h e m i d d l e
Choosemouseopr-m
fnoeitr
thedroTp-m
dhough
.uwnoen
e r ’ ewspecyfnigthemouse-
,thnistrucotinwil pneorti
go to m o u s e -pointer
wuosnailfgryoknriufgrer
. oactbenm
tl puetr
a d r o p - down menu.
Select Control
to reveal the
orange blocks.
b l o c k s c o n t r o l t h e way
s p r i t e s m o v e.
Now look at the top left
a green flag. S e l e c t t h i s
f l a g t o p l a. y
S CTCH
RA
Costumes
Sounds
Code
Events
Motion
when c l i c ke d
Looks
Sound
Events
Control
when clicked
forever
Sensing
go to mouse-pointer
Operators
Vari a b l e s
broadcast message1 x
Sprite Sprite1
My Blocks
Sprite1
Backpack
▷
M o v e y o u r m o u s e o r y o u r f i n g e r i f y o ure’
Well d o n e !
u s i n g a t a b l e t c o m p u t e r a n d w a t c h w h at
uoY h a v e c r e a te d y o u r f i r s t
h a p p e n s . I f y o u fo l l o w e d a l l t h e s t e p s , t h e
S c r a t c h p r o j e c t . L se ta’ d d
y o u r f i n g e r ) a r o u n d t h e s t a g e.
r e c t a n g l e . Le st c’ r e a t e s o m e a t m o s p h e re by
a d d i n g s c e n e r y a n d s o u n d e f f e c tosT. change
t h e s c e n e r ,y we a d d“ backdrop”
a i mage.
oT t h e r i g h t o f t h e s p r i t e s l i s t i s a
b u t t o n t o a d d a p i c t u r e f ro m t h e
b a c k d r o p l i b r a r. y C l i c k i t a n d l o o k f o r
“ U n d e r w a. t Se er l e2 c” t t h e i m a g e .
d e c o r a t i o n a n d d o e s ’tn
a f f e c t t h e s p r i t e s.
to open the
b a c k d r o p l i b r a r. y
Choose a Backdrop
Meow
0:85
of sounds.
uoY c a
as well as to sprites.
Press thi s i c o n
to choose a sound
f r o m t h e l i b r a r. y
S e l e c t t h e C o d e t a b a n d a d d t h e f o llowing
when
2 1
i n p l a c e a s y o u n e e d b o t h T. h e n e w c o d e
forever
r e p e a t s t h e b u b b l e s s o u n dT“. h e p l a y s o u nd
u n t i l d o nb el o” c k w a i t s f o r t h e s o u n d t o
E X P E R T T I P S
Loops
Blo
to
r e p e a t s o v e r a n d o v e r a g a i n The
.
“ f o r e v ebrl”o c k c r e a t e s a l o o p t h a t
when clicked
c a r r i e s o n f o r e ver, b u t o t h e r t y p e s
forever
o f l o o p s c a n r e p e a t a n a c t i o n a f i xed
programming languages.
l i b r a r. y Lo o k “Of o cr t o p ua ns ”d Motion in the blocks
theoctopusmoveeltand
f
Click here
to open
Octopus
the sprites
The octopus
l i b r a r. y
sprite will
block repe
appear in your
sprites list.
Choose a Sprite
N o w r u n t h e c o d eT. h e o c t o p u s w i l l p a t r o l l e f t a n d
5 1 61
r i g h t , b u t y o u ’ l l n o t i c e si tu’ p s i d e d o w n h a l f t h e
o c t o p su sc’o d e .
when clicked
forever
move 10 steps
f o r w a rd.
if on edge, bounce
Sensing blocks
Cat
touching Cat
if
81
t h e m i d d l e o f t“ihf ethen”
b l o c k . Th i s
stop all
w i l l s t o p a l l a c t i o n i f t h e o c to p u s i s
N o w a d d t“ihf ethen”
b l o c k s y o u ’v e b u i l t
This block
91
t o t h e o c t o p su sm’ a i n c o d e , p l a c i n g i t
when the
c a r e f u l l y a f t e r t h e b l u e M o t i o n b l o c k s. A l s o ,
sprites collide.
a d d“ wa a i t 0 . 5 s e c o n db se ”f o r e t h e l o o p.
“T hw ea bi lt o” c k a d d s a
s l i g h t d e l a y b e f o re t h e
when clicked
o c t o p u s s t a r t s moving.
forever
s “T ht eo p ab ll lo” c k o n l y
move 10 steps
“ t o u c h i bn lgo” c k i s y e s .
if on edge, bounce
touching Cat ?
if then
stop all
point in direction 13
when clicked
o c t o ps u s ’i z e t o 3 5 % .
set size to 35 %
point in direction 90
o c t o p u s w h i c h d i r e c t ion
E X P E R T T I P S N o w w e c a n d u p l i c a t e o u r o c t o p u s t o c r e a te m o r e
e n e m i e s . R i g h t - c l i c k ( i f y o ure’ u s i n g a m o u s e ) o r
D i r e c t i ons
l o n g - p r e s s ( i f y o u’re u s i n g a t a b l e t ) o n t h e o c t o p u s
i n t h e s p r i t e s l i s t a n d c h do o“ s e u .p lCi coapt ei e” s o f
S c r a t c h u s e s d e g r e e s t o s e t d i r e c t i oonY. u
c a n c h o o s e a n y n u m b e r f r o m – 1 7 9 ° to
a c o p y o f t h e f i r s t o c t o ps u s’ code.
p o s i t i v e n u m b e r s p o i n t t h e m r i g h t . Us e
0 ° t o g o u p a n d 1 8 0 ° t o g o s t r a i g h t d ow n .
Sprite Octopus
–90° moves a
0 °
Show
sprite straight
to the left.
– 9 0 ° 9 0 °
Cat
180° moves a
sprite straight
down.
1 8 0 °
right-click on a sprite.
when clicked
For m o r e v a r i e t, y l es t m’ a k e
52
set size to 35 %
a r a n d o m d i r e c t i o noT. d o t h i s ,
w e u s e a g r ep“ ei nc k r a n d o m ”
b l o c k . Th i s i s S c r as t c ’h way of
r o l l i n g a d i c e t o g e n e ra t e a
r a n d o m n u m b .e rC h o o s e
forever
t h e f i r s t o c t o p su sc’o d e . R u n
move 2 steps
t h e o c t o p u s c h o o s e d i f f e re n t
if on edge, bounce
s t a r t i n g directions.
if touching Cat
stop all
E X P E R T T I P S
Random numbers
when c l i c ke d
b e c a u s e t h e y m a k e d i f f e r e nt t h i n g s
h a p p e n t o e a c h p l a y e. rA r a n d o m
n u m b e r i s o n e y o u c a n’t p r e d i c t i n
uoY c a n g e t t h e c a t t o s a y a r a n d o m
This block picks a random
number from 1 to 6.
d i c e r o l l u s i n g t h i s s i m p l e c o d e.
Cat Octopus Octopus2 Octopus3
Star
A d d t h e f o l l ow i n g c o d e t o S [Link] s c o d e w i l l m a k e t h e s t a r
72
move to a random ne w l o c a t i o n w h e n e v e r t h e c a t t o u c h e s i t.
T h e g r e e n b l o c k s c re a t e r a n d o m n u m b e r s c a l l e d co o r d i n a t e s ,
when clicked
forever
oT s e e t h e s t sa rc’o o r d i n a t e s c h a n g e w h e n i t
Star: x position
82
t h e g a m e : y o u ’ l l s e e t h e s t sa rx’ a n d y c o o r d i n a t e s
Star: y position
u p d a t e e a c h t i m e t h e c a t m a k e s i t m o ve . U n t i c k
(x:–190, y:–150)
uoY c a n a d d a s o u n d e f f e c t t h a t p l a ys
w h e n t h e c a t t o u c h e s a s t .a rFirst
92
a b o v e t h e b l o c k s p a l e t t e. S e l e c t t h e
l i b r a r y a n d c h o o“asF e i r y .d uN so wt ”
t h e s t sa rc’ o d e a n d c h o o“asF e i r y d u s t ”
I n s e r t s t“ ht ea r t s o u nb dl o” c k
in the drop- down list.
i n t o t h e S tsa re ’x i s t i n g c o d e ,
t o c h o o s e w h i c h s o u n d t o p l a. y
Vari a b l e s
M a k ea Var i a b l e
Click here to
my variable
create a new
variable.
set m y va r i a b l e to 0
change my variable by 1
f o r e v e r y sprite.
o u’ Yl l s e e a s e t o f n e w b l o c k s a p p e ,a ri n c l u d i n g
23
o n e f o r t h e s c o r e. M a k e s u r e t h e b o x n e x t t o i t i s
t i c k e d t o m a k e t h e s c o r e a p p e a r o n t h e s t a g e.
Vari a b l e s
M a k ea Var i a b l e
my variable
uoY c a n m o v e
t h e s c o r e d i s p l a y to
set m y va r i a b l e to 0
change my variable by 1
change Score by 1
N o w c l i c k t h e g r e e n f l a g to
53
c o l l e c t s e a c h s t .a rS e e i f y o u
E X P E R T T I P S
Variables
s u c h a s x a n d y . I n c o m p u t e r p r o g ramming,
w e g i v e v a r i a b l e s n a m e s s u c h “aSs core”
and
a n y k i n d o f i n f o rmation. rT y t o c h o o s e a
n a m e t h a t t e l l s y o u w h a t t h e v a r i a b l e i s f o, r
s u c h “aSsp e e“[Link]”core”
ost computer
l a n g u a g e s w o n’t l e t y o u p u t s p a c e s i n t h e
c o m b i n e w o r d s. I n s t e a d o f u sdi n“ g o g s p, e e d ”
f o r i n s t a n c e , t y p“ De o g S p. e e d ”
when clicked
set size to 35 %
forever
the chase.
move 5 steps
touching Cat ?
if then
stop all
Score
uoY c a n m a k e t h e g a m e g e t h a r d e r a s y o u p l ay.
83
Vari a b l e s i n t h e b l o c k s p a l e t t e . D r a g t“hScore”
e
move 2 steps
b l o c k i n t o t h e o c t o ps u s’“ move”
block. Now
t r y t h e g ame. Th e m o r e p o i n t s y o u g e t , t h e
move
93
R e a r r a n g e tm“hbove”
el o c k s o i t l o o k s l i k e t h e
i m a g e b e l o wyT. “p3e” i n t h e s e c o n d r o u n d w i n d o .w
Sound
turn 15 degrees
Events
go to random position
Control
go to x: 0 y: 0
Sensing
Operators
when clicked
glide 1 secs to x: 0 y: 0
set size to 35 %
Vari a b l e s
point in direction 90
My Blocks
forever
stop all
14
It should swim in a
Score 0
repeating triangle
pattern.
oT c h a n g e t h e s h a p e
different number s in
g l tide”
“he b locks.
▽
Debug Octopus2
o f a g a m e , i t c a n t r a p t h e p l a ye r i n t h e n e x t g a m e a n d
e n d i t t o o q u i c k Tl. yh i s i s a b u goT. f i x i t , y o u c o u l d d r a g
is t b’ e t t e r t o u s e c o d e t h a t m ov e s i t a u t o m a t i c ally. I n s e r t
g “ a obto”
l o c k a t t h e s t a r t o f t h e c o d e f o r O c to p u s 2 t o
Octopus2 can
in the top-right
c o r n. e r
c e n t r e o f t h e s t a g e.
when clicked
go to x: 0 y: 0
Hey!u Tr n m e b a c k
into a cat!
Scuba diver
oT m a k e t h e u n d e r w a t e r t h e m e m o r e
c o n v i n c i n g , r e p l a c e t h e c a t w i t h a d i ve.r
uoY c a n c h a n g e h o w e a s y t h e g a m e i s b y a d j u s t i n g
o c t o p u s be lsm“u’ bove”
el o c k s t o a l t e r t h e i r s p e e d .
sprite symbo l t o o p e n t h e l i b r a r, y
C h a n g e t h e p u r sp“ l eet s i z e bt ol o” c k s t o m a k e s p r i t e s
l a r g e r o r s m a l l .e rF i n e - t u n e t h e n u m b e r s u n t i l t h e
set size to 50 %
Swimming animation
when clicked
oT a d d a p r o f e s s i o n a l to u c h t o S t a r
Hunter, a n i m a t e t h e o c t o p u s e s s o
forever
t h e y l o o k l i k e t h e y ’ re s w i m m i n g .
next costume
Add this code to an empty part of
d i f f e r e n t p o s e s.
C h e e s e
C
monsters and collecting goodies.
A I M O F T H E G A M E
a v o i d t h e e v i l b e e t l e s. A n d w a t c h o u t for
◁ Mimi
u o Y playthegameasthemouse.
◁ Beetles
Ghosts
◁
walls. Th e y c a n a p p e a r
a n d t h e n d i s a p p e .a r
uoY c a n c r e a t e a
pattern of walls.
a m o u s e ) o r l o n g - p r e s s i n g ( i f y o u’re u s i n g a and in the sprites list.
x y
Sprite Sprite1 0 0
t h e s p r i t e s l i b r a r. y
Choose a Sprite
Sprite1
duplicate
export
delete
T h e p l a y e r m o ve s t h e m o u s e s p r i t e u s i n g t h e oT m a k e t h e s p r i t e l o o k m o r e l i k e a g a m e p a d , you
3 4
k e y b o a r d a r r o ws , o r ( i f t h e yre’ p l a y i n g o n a c a n c h a n g e t h e w a y i t l o o k s u s i n g S c r as tch’p a i n t
uoY c a n m a k e t h e g a m e p a d b y a d d i n g a n e w a n d t h e n c l i c k t h e C o s t u m e s t a b.
s p r i t e . S e l e c t t“Ch he o o s e a S p r i st ye m” b o l
a n d a d d t h e B u t t o n 1 s p r i t e f r o m t h e l i b rary.
C h a n g e t h e s p r si t e ’
n a m e to “Gamepad”
Code
in this box.
Sprite G amepad
S h ow S i ze 100
button1
84 x 84
Mouse1 G amepad
T h e s m a l l c i r c l e w i l l a l w ay s p o i n t i n
t h e d i r e c t i o n t h e p l a ye r t o u c h e sT. h i s
Now select the Code tab and add this code to the Gamepad
6
sprite.
The gamepad will only appear when the player is touching
the screen. Run the code and move your finger around the game
area. Th e g a m e p a d b u t t o n w i l l a l w a ys p o i n t t o w a r d s t h e
d i r e c t i o n o f y o u r f i n g .e r
t o t h e b o t t o m l e f t o f t h e s c r e en
w h e n t h e g a m e s t a r t s.
when clicked
go to x: –175 y: –110
forever
hide
point in direction 50
mouse down?
if
then
show
key u p a r r ow
8
make the mouse sprite move up using
t h e a r r o w k e y o r t h e g a m e p a d . Th e
S t a r t b y k e e p i n g t h e b l o c k s a p a r t.
C o n n e c t t h e b l o c k s t o g e t h, e r
m a k i n g s u r e t h e o r d e r i s co r r e c t .
or
when clicked
forever
if
point in direction 0
move 5 steps
move 5 steps
if
move 5 steps
if
point in direction 90
move 5 steps
if
move 5 steps
are correct.
N o w p r e s s t h e g r e e n f l a g t o r u n t h e c o dueoY.
01
should be able to move Mimi in all directions
a r o u n d t h e s t a g e u s i n g t h e a r r ow k e y s o r t h e
g a m e p a d . I f si tn’ o t w o r k i n g , g o b a c k a n d
p l a y e r t o u c h e s t h e s c re e n .
Costume costume1
Fill
Paintbrus ht o o l
Convert t o V e c to r
[Link]
2 1
toolandchooseblackfromthecolourpalette
[Link]“Fi”lawinthetheoutlineofthecheese.
Ifyouwantper ectl
f ystraightlines,usetheline
ourcheese
[Link] drawingmightbetoobigat
first,[Link]
If your colour spills out and fills the
don’t h a v e a ny g a p s , t h e n t r y a g a i n .
to the game.
oT k e e p s c o r e , we n e e d t o c r e a t e a
Vari a b l e s
5 1
v a r i a b l e c a l. l“CeScore”
hd o o s e aV r i a b l e s
i n t h e b l o c k s p a l e t t e a n d s e l e“ Mc t a k e a
M a k ea Var i a b l e
TVari
. y pable”
e t h e w o“ rScore”
din the
p o p - u p b o x . S e l e c t t h e c h e c k b ox beside
my variable
t h i s n e w v a r i a b l e a n d t h e s c o r e c o unter
Score
61
when clicked
the player will score 10 points, and the cheese will move to a new
set Score to 0
e a s y – b u t t h sa tb’ e c a u s e y o u h a v e n’t a d d e d e n e m i e s y e t . . .
forever
change Score by 10
hide
forever
Choose a Sprite
Ghost
move 1 steps
Click here
The ghost
to open
is now your
if
touching Mouse1
t h e l i b r a r. y
selected sprite.
stop all
S t a r t s a new block
h a v e t w o co d e b l o c k s .
when clicked
91
a p p e a r a n d d i s a p p e a r f o r r a n d o m a m o u n t s o f t i m e.
forever
“ s h omwa” k e s i t a p p e a r a g a i n .
hide
pick random 5 to 10
wait seconds
show
pick random 3 to 6
wait seconds
o n s c r e e n f o r 3 – 6 s e co n d s .
The sound
repeats until
C l i c k t h e s p e a k e r s y m b o l t o o p e n t h e s o u n d l i b r a r. y
12
“. XRyel op 1e ”a t t h e p r o c e s s t o l o“aDda n c e C e l e b r a t e”
s o u n d l i b r a r. y
Choose a Sound
s o u n d f “.r p“oto
XyRop”
mluon1 ”t h e g a m e a n d t h i n k
a b o u t h o w i t f e e l s t o play. N e x t t r y t h e s o u“nDda n c e
Celebrate”
. Whi c h o n e i s b e t t e r ?
forever
a n d r e n a m e t h e s p. r “i Mt e aze”
Mouse1 G amepad
N o w y o u c a n s t a r t u s i n g t h e p a i n t e d i t .o rS e l e c t t h e
24
“ C o n v e r t t o B i t m ba pu”t t o n t o c h a n g e t h e m o d e .
Choose the line tool and set the line width to 20.
Costume costume1
20
Fill
y o u s t a r t drawing.
Line tool
in the empty
space here.
Convert t o V e c to r
Convert t o V e c to r
F i n a l ,l y we n e e d t o a d d s o m e c o d e t o m a k e
62 72
s u r e t h e m a z e i s a l w ay s i n t h e c e n t r e o f t h e
s t a g e s o si tf ’u l l y v i s i b l e Wit
. h the Maze sprite
f o l l o w i n g c o d e.
when clicked
go to x: 0 y: 0
A t t h e c e n t r e of
the stage, x is 0
and y is 0.
point in direction 90
the cheese.
uoY m i g h t n e e d t o f i n e - t u n e y o u r M a z e
03
c o s t u m e t o m a k e s u r e M i m i c a n f i t t h ro u g h
a l l t h e p a s s a g e s , w i t h e n o u g h r o o m to p a s s
h e r e n e m i e s ( w h i c h w er e’ g o i n g t o a d d
later).
o Ta l t e r t h e m a z e , s e l e c t t h e M a z e
s p r i t e a n d c l i c k t h e C o s t u m e s t a b. U s e
I f y o u u s e t h e e r a s ,e rb e c a r e f u l n o t t o l e a ve a n y
13
t h a t M i m i m i g h t g e t s t u c k o n a n d r e m o ve t h e m .
Try d i f f e r e n t
colours to see
G A M E D E S I G N
Space in games
h a s a b i g e f f e c t o n h o w you play. A m a z e
Wall s r e s t r i c t
i s t h e p e r fe c t o b s t a c l e t o d e m o n s t ra t e t h i s .
movement.
△ △
T h e p l a y e r c a n m ov e i n a n y T h e p l a y e r i s fo r c e d t o m o v e i n a v e r y
A game like this needs fast- the corridors of this maze would make
53
when clicked
m a i n c o d eoT. m a k e c o p i e s , r i g h t - c l i c k
( i f y o ure’ u s i n g a c o m p u t e r ) o r l o n g -
forever
p r e s s ( i f y o u’re u s i n g a t a b l e t ) o n t h e
n e w b l o c k s a n d s edl e“ c t u .p l i c a t e ”
if key u p a r r ow
P l a c e t h e d u p l i c a t e s a f te r e a c h
“move 5 s t ebp sl ”o c k .
point in direction 0
move 5 steps
if key d o w n a r row
move 5 steps
move –5 steps
if
key r i g h t a r row
point to direction 90
I n s e r t the new
move 5 steps
blocks four
m o su s ce o’ d e .
if
key l e f t a r row
move 5 steps
I f M i ms it ’a i l o r p a w s t o u c h a w a l l w h e n s h e
t u r n s a r o u n d , s h e c a n g e t s t u c k We
. can fix
63
I f M i ms it a’ i l o v e r l a p s
t h i s b u g b y m a k i n g s o m e c h a n g e s t o M i ms i ’
c o s t u m e i n t h e p a i n t e d i t .o r
stop moving.
the Cost u m e s t a b a b o v e t h e b l o c k s p a l e t t e.
73
C h o o“Cos en v e r t t o B i t m a tp ”t h e b o t t o m ,
andthenusetheerasertooltotrimstaiMi
l. mi’
Costume mouse1-a
40
Fill
Convert to Vecto r
C l i c k t“Ch he o o s e a S p r i t e ”
93
s p r i t e f r o m t h e l i b r a r. y
Run [Link]:thebeetle
14
alwaysturnsrightandendsupgoingorund
Beetle
The beetle is
inloWops.
eneedtochangethecod esothatthe
now your
beetleturnsleftorrightatorandom.
T make a
selected sprite.
r a n d o m c h o i c e , u s p“e i ac k r a n d obml ”o c k . D r
A d d t h e f o l l ow i n g c o d e t o s e t t h e b e es t l e’ size,
40
l o c a t i o n , a n d d i r e c t i o n . I t u s e “s f ao r e v leor o” p t o
m o v e t h e b e e t l e , a n d “iaf nthen”
block to make it
s t o p a n d t u r n r i g h t w h e n e v e r i t h i t s a wall.
uoY m a y n e e d t o c h a n g e
when clicked
b e e t l e s t a r ts on a wall.
set size to 30 %
go to x: –130 y: 80
This block
makes the
point in direction 90
N o w d r a g tp“hi ec k r a n d obml o” c k i n t o
beetle reverse
42
forever
right when it
hits a wall.
“ i f t h e n e l s e” block.
move 5 steps
if
This block
move –5 steps
makes the
beetle
turn right.
R e m o v e t“ ht eu r n 9 0 d e g r e be sl o” c k f r o m t h e b e e tsl eo’ r i g i n a l c o d e a n d
44
p u t t“ihf et h e n e l bs el o” c k i n i t s p l a c e , a s b e l o .w R u n t h e p r o j e c t a n d
w a t c h w h a t h a p p e n s . C h e c k there’
s e n o u g h r o o m f o r M i m i to s q u e e z e
p a s t t h e b e e t l e . I f n o t , a d j u s t t h e m a z e i n t h e p a i n t e d i t .o r
when clicked
set size to 30 %
go to x: –130 y: 80
point in direction 90
forever
move 5 steps
move –5 steps
pick random 1 to 2 = 1
if then
turn 90 degrees
else
turn 90 degrees
when clicked
set size to 30 %
go to x: –130 y: 80
point to direction 90
forever
move 5 steps
touching Maze ?
if
then
move –5 steps
if pick random 1 to 2 = 1
then
turn 90 degrees
else
turn 90 degrees
touching Mouse1
if
broadcast message 1
spritebyright-clickingorlong-pressingonit
48
(usecontrol-clickifyouworkonaMac)and
Show
dthen
.Makechoosi
“ threennew
uplgciate”
beet
These
les. wilallhavethesamecode.
Seewhathappenswhenyouruntheproject.
Sprite1
S ed l ue“pcl itc a t e ” to
b l o c k s f o r e a c h n e w b e e t l e s o t h e y d o ’nt a l l s t a r t
94
w o r k s q u i t e w e l l. E x p e r i m e n t !
Beetles start
in corners.
Score 30
c a l l“eHdi g h. SA c no er e”w b l o c k w i l l a p p e ,a r
a n d t h e h i g h s c o r e c o u n te r w i l l a p p e a r o n
High Score
For a l l s p r i t e s
when clicked
15
e a c h t i m e t h e p l a y e r g a i n s p o i n t s. R u n t h e p r o j e c t
set size to 70 %
a n d s e e i f a n y o n e c a n b e a t y o u r h i g h s c o r e.
set Score to 0
forever
change Score by 10
i“T fh tehbelno” c k t e s t s
b e c o m e s t h e n e w h i g h s c o r e.
.Usedinigt”oCrnvertto
,drawarectangl
Btmi aep”
andfilitwithadark t o e n l a r g e t h e t e x t.
.colNow
ourswitchto
.C“onvVer totctor”
Chooseabrightcolour
andusethetexttoolto
GAME
GAME
“ type
inthe
OVER!”
[Link]
OVER!
“SansfontSeri
toand
f ”
usetheselectiontool
tomakethetextlarge.
Convert to Bitmap
uoY don’t w a n t t h e
35
“ G A M E O V E sRign
!”
when clicked
g a m e i s r e a l l y o v ,e r
hide
s o l se th’ i d e i t w i t h
“GAME OVER!”
signinth e m i d d l e .
54
go to x: 0 y: 0
t h e g a m e e noduYs.
go to front laye r
Mimi to trigger
show
this code.
Play on
uoY n e e d t o p l a y t h e g a m e a l o t
c a n b e i m p r o v e d. G e t o t h e r p e o p l e
toouYplay
can
. adjust many
aongi:autcoirngfhitrhetget g a m e
score. Th e r e a r e l o t s o f s o u n d s i n S
w h e r e t h e a b i l i t i e s o f t h e p l a ye r
a n d e n e m i e s a r e w e l l b a l a n c e d.
Twea k t i m i n g s
uoY m i g h t f i n d C h e e s e C h a s e h a r d e r
you can make the beetles slowe r or the enemies for 10 seconds when
time.
o uY c a n a l s o s p e e d u p M i m i . F o r you would need to add a new spr
at a different s p e e d . s h o w c o d e b l o c k i n e a c h e n e m. y
Vani s h i n g c h e e s e
For a n e x t r a c h a l l e n g e , m a k e t h e c h e e s e s p e n d o n l y 1 0 s e co n d s o r
s o i n e a c h s p o t b e f o r e m o v i n g t o a n e w l o c a t i o n T. h i s w i l l f o r c e t h e
when clicked
p l a y e r t o m o ve f a s toT. d o t h i s , g i v e t h e c h e e s e a n e x t r a c o d e b l o c k
w i t h“ f ao r e v leor o” p c o n t a i n i n g“ waa i t 1 0 s e c o n db sl o” c k , f o l l o we d
forever
b y a c o p y o gf t“ h e obto”
lock from the main code.
wait 10 seconds
random location
t h e p r o j e c t p a g eoY. u n e e d t o l o g i n t o a n
s t a r t p l a y i n g . H e r e a re three
w a y s o f i n c l u d i n g i n s t r u c t i o n s.
Cheese Chase
Instructions sprite
Score 30
uoY c a n u s e t h e p a i n t e d i t o r t o c r e ate
s p r i t e . G i v e i t t h e f o l l o w i n g co d e t o
g a m e a n d t o h i d e i t o n c e t h e p l a yer
p r e s s e s a n y w h e re o n t h e s c r e e n .
0 0 0 1
when clicked
go to x: 0 y: 0
go to front laye r
a n y w h e r e o n t h e s c re e n .
show
mouse down?
wait until
hide
A d d t“hwi sa i t u n tb il lo”c k
t o t h e s t a r t o f e v e r y other
s p rsi t ce ’o d e s o t h e y d o n ’t
when clicked
game begins.
set size to 35 %
mouse down?
wait until
which can turn a single sprite into
a n a r m y o f s i n i s t e r co p i e s .
A I M O F T H E G A M E
t o c o l l e c t t h e p a l e g re e n c i r c l e s, b u t
a v o i d t h e r e d o n e s t h a t m a r c h t o wards
y o u l i k e a z o m b i e a r [Link] s o l i d
o f t h e m s e l v e s a s t h e y r o a m a ro u n d .
Player
I f y o u d o ’nt k e e p m o v i n g
w i l l s o o n o v e r w helm you.
Friends
T h e f r i e n d l y c i r c l e s a re g r e e n .
W h e n y o u t o u c h o n e , you
s c o r e a p o i n t a n d t h e c i rc l e
Enemies
S t e e r c l e a r o f t h e r e d e n e my
c i r c l eusoT. c h o n e a n d i t t a k e s
t h r e e p o i n t s o f f y o u r s c o r e , b e fore
T h e s o l i d g r e e n c i rc l e l a y s
c i r c l e c h a s e t h e p l a ye
.r c i r c l e c h a s e t h e p l a ye
.r
menu to paint a new sprite. Bitmap”
(bottom left).
Paint
a t t h e t o p o f t h e p a i n t e d i t .o r
C l i c k w i t h t h e m o u s e o r y o u r f i n g e r i f y o ure’
E X P E R T T I
a c o m p u t ,e rh o l d i n g d o w n t h e s h i f t k e y w i l l
g i v e y o u a c i rc l e r a t h e r t h a n a n o v [Link] e c i r c l e
Whenyou’
re happy with thes circle’ size, delete
too small, you can change
t h e c a t s p r i t e . R e n a m e t h e n e w s p r “i tPe. l a y e r ”
its size by using the
“Select”
A r o t a t i o n t o o l w i l l a p p e a. r
Costumes tab. C h o o s e g r e e n i n t h e
c o l o u r p a l e t t e . S e l e c t t “hFill”
teo o l a n d
turn green.
7 Sprite Enemies
x
20
t h i s s p r i t e r e doY. u
t h r e e d i f f e re n t
c o l o u r e d s p r i t e s.
N o w a d d a s c o r e d i s p l ay a n d s o m e c o d e
t o m a k e t h e P l a y e r s p r i t e m o v e w h e re v e r
y o u m o v e i t to – j u s t l i k e i n S t a r H u n t e. r
Select the
8
New
Va r i a b l e
P l a y e r s p r i te,
cl ickVa r i a b l e s ,
variable called
Score
. “Score” T h e n
tick this
v a r i a bs l ec’h e c k
For a l l s p r i t e s oF r t h i s s p r i t e o n l y
box to show
“Score”
on
Cancel OK
the stage.
S e l e c t t h e g r e e n Fr i e n d s s p r i t e .
forever
01
point in direction
d i r e c t i o n e v e r y 2 5 0 s t e ps.
repeat 25
move 10 steps
if on edge, bounce
w a t c h t h e g r e e n c ircle’
s
1 1
u n p r e d i c t a b l e j o u rney. The
Friends s p r i t e m o v e s 2 5 0
doesn’t g e t s t u c k t o t h e w a l l s.
E X P E R T T I P S
A f t e r 2 5 0 s t e p s, t“hf eo r e v e r ”
Repeat loops
l o o p g o e s b a c k t o t h e s t a r t.
T h e s p r i t e c h a n g e s d i r e c t ion
uoY’ v e a l re a d y s e e n
“ f o r e v el or ”o p s t h a t
Random direction
nonstop.“reAp e al to”o p
changes happen
e v e r y 250 steps.
t i m e s Thi
. s type of loop
is sometimes called a
“ f oloop,
r ” because it
for
repeats a c e r t ain
n u m b e r o f t i m e s The
.
r e p e a t s a n a c t i o n f o ur
t i m e s t o d r a w a s q u a r e.
of the Fr i e n d s s p r i t e a f t e r
create clone of my s e l f
31
d i r e c t i o n , t h e s p r i t e l e av e s a c o p y
o f i t s e l f – a c l o n eT. h e c l o n e s a r e ’nt
j u s t p i c t u r e s – t h e y a r e f u l l y wo r k i n g
c o p i e s o f t h e o r i g i n a l s p r i t e, a n d y o u
c a n g i v e t h e m t h e i r o w n i n s t r u c t ions.
41
t“hwe h e n I s t a r t a s a c l o nb el ”o c k .
A d d t h e c o d e b e l o w to t h e F r i e n d s
All clones run thei
t o m o v e t o w a r d s t h e P l a y e r s p r i te
stage. Th e c l o n e s m o v e o n e s te p
a t a t i m eT. h e y m o v e m o r e s l ow l y
repeat 300
w h i c h m o v e s i n 1 0 - s t e p j u m p s.
move 1 steps
R u n t h e c o d e a n d w a t c h t h e g re e n
5 1
c l o n e s a d v a n c e s l o w l y t o wards the
P l a y e r s p r i t e. Don’t w o r r y – t h e y ’ re
P O P !
E X P E R T T I P S
Clones
o f c o p i e s o f a s p r i t e . M a n y p r o g r a m m i ng l a n g u a g e s a n d i n c l u d e J a v a a n d C + + . I n S c r a tch,
languages let you make copies of things, but there are thre e orange blocks that contro l
they are often called objects rather than clones. clones, all found in the Control s e c t i o n .
create clone of my s e l f
△ △
t h e y c a n r u n a l l o t h e r c o d e b l o c k s i n t h e s p rs i t e’ code
Player
Friends
S e l e c t t h e E n e m i e s s p r i t e T. h e
81 Undo
Redo
a n o t hoT.e r e a r r a n g e t h e m ,
right-click (ifyou’
re using a mouse)
Clean up Blocks
o r l o n g - p r e s s ( i f y o u’re u s i n g
Add comment
a n d s e l e“Cc lte a n u p B. l o c k s ”
Delete 19 Blocks
change Score by –3
91
c o d e s o t h a t i t t a k e s p o i n t s a w ay
A l t e cr t“h e h a n g e S c o r e bb yl o” c k s o
o+1.u Y r e a l l y w a n t t o a vo i d t h o s e
p o i n t s h a v e b e e n l o s t . Lo a d t h e
s p r i t e b y s e l e c t i“Cyn gm b ianl ”t h e
s o u n d l i b r a r. y A l t e r t h e c o d e t o p l a y
“Cymba
, oYnot
. u’ l l ”pln”op”
ow hear
w h i c h t y p e o f c l o n e y o u ’v e t o u c h e d .
R u n t h e p r o j e c t . C h e c k t h a t y o u now
12
3 p o i n t s o f f y o u r s c o re.
I f t h e s c o r e i s g re a t e r t h a n 2 0 , y o u w i n , a n d
think Vi c to r y !
a t h o u g h t b u b b l e w i t h t h e w o“ r d Vi c t o r y ! ”
a p p e a r s . I f t h e s c o re i s l e s s t h a n – 2 0 , y o u
l o s e , a n d t h e s p r i t e t h i n“ kDse f e a t ! ”
if Score
Victor y ! Defeat!
think Defeat!
L I N G O
Comparison operators
E a r l i e r w e s a w h o w y o u c a n u“isfethen”
blocks W h e n w e a d d t h e s e “itfothen”
b l o c k s , t h e y c r e a te
o u t c o m e s . oF r e x a m p l e , i n S t a r H u n t e, “irf you’ve wo n t h e g a m e w h e n y o u s c o r e o v e r 2 0 .
t o u c h i n g c a t t h e n s t a r t sound Fa i r y d u s mt ”a k e s
a s o u n d p l a y o n l y w h e n t h e c a t g e t s a s t [Link]
if
w h a t a r e c a l l e d c o m p a r i s o n o p e r at o r s :
think iV c t o r y !
2 < 5 3 = 3 5 > 1
set Score to
game, you can include an on-screen
reset timer
forever
go to m o u s e -pointer
Gototheariables
V section and make a
24
variable
“ forTiallme”sprites
o Tshow
.
the variable’
s block. Choose the Player
think Vi c to r y !
palette.
r“eset
Add timer”
to the Player’
s
Gobacktoariables
V andsdrag
“ Time
et a
foreverloop.
if Score
think Defeat!
B y c o p y i“ntgi m et or ” t h e v a r i a b l e
52
“, eT aicme”
h trip around the loop will
l o s e s , t h e t i m e s t o p s b e i n g u p d a ted
set Ti m e
Time 41.573
I think it must be
lunch time!
toT a l n u m b e r
of seconds
in the game.
Use black
f o r t h e t e x t.
“ Ft iol lo” l
o Y u a r e t h e b l u e c i r c l e.
72
c o l o u r f o r t h e t e xt. Th e n c h o o s e t h e t e x t t o ol
a n d t y p e o u t t h e i n s t r u c t i o n s s h o w n h e r e.
Try t o t o u c h t h e f r i e n d l y g r e e n c i r c l e s .
Avoid t h e e n e m y r e d c i rcles.
“ e x tTto o” l
I f t h e t e x t doesn’t f i t , u s e t h e s e l e c t t o o l t o
S c o r e l e s s t h a n – 2 0 a n d yo u l o s e .
82
out. Wh e n y o u ’v e f i n i s h e d , c l i c k o u t s i d e t h e
Press anyw h e r e o n t h e s t a g e t o s t a r t !
b o x a r o u n d t h e te x t t o s t o p e d i t i n g.
“ S e l e ct ot o” l
G A M E D E S I G N
Game stories
C o m p u t e r g a m e s u s u a l l y h a ve a s t o r y t o e x p l a i n w h y t h e
Wars h a s n o s t o r .y Ca n y o u m a k e o n e u p ? I t c o u l d b e a
b a t t l e i n s p a c e , w i t h a b l u e s p a ce s h i p s a v i n g f r i e n d l y
g r e e n s p a c e s h i p s a n d t r y i n g t o a v o i d b e i n g h i t by t h e r e d
e n e m y c r a f t . Le t y o u r i m a gi n a t i o n r u n r i o t ! I n c l u d i n g
t h e g a m e m o r e i n t e r e s t i n g a n d e x c i t i n g f o r t h e p l a y e. r
hide
when clicked
uoY a l s o n e e d t o a d d
03
“ a w a i t u n t i l m o u s e d o w ”n
Player, F r i e n d s , a n d E n e m i e s
s p r i tceosd’ eT. h i s w i l l h o l d
set Score to 0
reset timer
p r e s s a n y w h e re o n t h e s t a g e .
forever
go to m o u s e -pointer
13
i n s t r u c t i o n s s h o u l d a p p e ,a r
if Score
p r e s s a n y w h e re o n t h e s t a g e .
think Vi c to r y !
P l a y e r s w i l l h a ve p l e n t y o f t i m e
t h e g a m e w h e n t h e y ’ re ready.
if Score
m’ I r e a d y
think Defeat!
to play!
time
set Ti m e to
▽
W hs atth’ e s t o r y ?
D i d y o u t h i n k o f a s t o r y t o e x p l a i n w h sa tg’ o i n g o n i n
Circle Wa r s ? M a y b e si tt ’h e a t t a c k o f t h e d r a g o n s , a n d
t h e p r i n c e s s p l a y e r h a s t o e a t c a k e s t o s u r v ive? Add
story. E x p e r i m e n t w i t h d i f f e r e n t s t o r i e s a n d l o o k s .
T h e ws aover!
r’
A d d a b r o a d c a s t m e s s a g e to
r e v e a l a G a m e O ve r s p r i t e w h e n
t h e p l a y e r w i n s o r l o s e s, l i k e y o u
d i d i n C h e e s e C h a s ueoY. c a n
c h a n g e t h e t e x t o f t h e G a m e O ver
s p r i t e s o t h a t i t r e l ates to your
go to m o u s e -pointer
oT m a k e t h i n g s t r i c k y , c h a n g e t h e
bluescicode
rcle’ so that it no longer
to where
“sitcks” you tell it to go but
Remove the
og“b lto”o c k .
move 5 steps
controls fo r t h e s p r i t e .
Twea k t h e t i m e r
d e c i m a l p l a c e soT. r o u n d t h e v a l u e s o i t s h o w s o n l y w h o l e
s e c o n d s , u s e t h e g rer“eo nu nbdl o” c k n e a r t h e b o t t o m o f
t h e O p e r a t o r s s e c t i o nr T. y a d d i n g“ Bae s t t i mf oe r” w i n n i n g
repeat 300
a f “t ew rh e n I s t a r t a s a. c l o n e ”
From gre e n
Operator
A d dc t“ h e h a n g e s i z e bb yl o” c k t o
a r a n d o m s i z e . A l te r t h e s c o r i n g s o
t h a t t h e s i z e o f t h e c i r c l e yo u t o u c h
d e t e r m i n e s h o w m a n y p o i nts you
score.
o u’ Yl l a l s o n e e d to c h a n g e repeat 300
t h e t o t a l s n e e d e d t o w i n o r l o s e Tr. y
m o r e t h a n 2 0 0 0 p o i n t s f o r v i c t o r, y
Change the Fr iends’
s c o r e v a l u e t o t h i s.
a n d l e s s t h a n – 2 0 0 0 f o r d e f e at.
Use this
scoring for
Enemies.
J u m p y
M o n k e y
P R E S S
M o n k e y s h o w s yo u h o w t o a d d
g r a v i t y t o yo u r g a m e w o r l d s.
A I M O F T H E G A M E
l e a p s i n a n d h o w f a s t h e g o e suoY. n e e d
t o s e n d h i m o v e r t h e p a l m t re e t o g r a b t h e
b a n a n a s u s i n g t h e f e w e s t p o s s i b l e j u m p s.
Launcher
Point th i s a r r o w i n t h e
m o u s e o r y o u r f i n g .e r
Monkey
S e l e c t t h e m o n k e ys l ’a u n c h
s l i d ,e tr h e n p r e s s t h e L a u n c h e r
Bananas
t h e m o n k e y c a n ’t
to rename
Arrow1
Monkey
the sprite.
x y
Sprite Sprite1 -36 -14
Monkey Launcher
when
you’re u s i n g a t a b l e t ) T. h e d i r e c t i o n o f t h e a r r ow i s t h e
set LaunchSpeed
direction that the monkey will launch in. Run the code
a n d t r y t u r n i n g t h e a r r o w b y m ov i n g y o u r m o u s e o r
go to x: –200 y: –140
go to front
forever
w i t h t h e p l a yse rm’ o u s e - p o i n t e r o r
t h e d r o p - down menu.
hide
LaunchSpeed
11
normal readout
large readout
using a tablet) to
slider
of the variable.
hide
L I N G O
Events
a c o m p u t e r d e t e c t s a r e k n o w n a s e v e n t s.
when spa
T h e y e l l o w E ve n t s b l o c k s i n S c r a tc h t r i g g e r
occurs. We’ve s e e n t h e m u s e d w i t h m e s s a g e s
when this s
i n C h e e s e C h a s e , b u t S c r a tc h a l s o l e t s y o u
s o u n d l e v e l s , a n d e v e n m o v e m e n t d e t e c te d
b y a w e b c a m . D o n’t b e a f r a i d t o e x p e r i m e n t .
when lou
E v e n t s b l o c k s s u c h a s t h e s e a re u s e d t o t r i g g e r
n e w c o d e t o t h e M o n k e y s p r i t e.
“ R e p e a t u n ti isl ”a n e w t y p e o f l o o p
go to Launcher
point in direction
move LaunchSpeed
r“Tehpe e a t u n tb il lo”c k
go to Launcher
E X P E R T T I P S
“repeat until”
D o y o u w a n t t o k e e p re p e a t i n g a n a c t i o n o n l y u n t i l s o m e t h i n g h a p p e n s
a n d t h e n g e t o n w i t h t h e r e s t o f t h e c o d e ?The
“re p e a t u n t bi ll”o c k c a n
M o s t p r o g r a m m i n g l a n g u a g e s u s e s i m i l a r l o o p s, b u t s o m e c a l l t h e m
while
“while”
loops – these continue t h e c o n d i t i o n i s t r u e , r at h e r t h a n
until
looping t h e c o n d i t i o n i s t r u e The
. r e a r e a l w a ys d i f f e r e nt w a y s t o
b a n a n a s . B y u s i n g c l o n e s , yo u c a n a d d j u s t o n e B a n a n a s
s p r i t e b u t g i v e t h e m o n k e y p l e nt y o f f r u i t t o a i m f o. r
M a k e a v a r i a b l e f o r a l l s p r i te s c a l l e d
“ N u m B a n a n to
a s ”k e e p t r a c k o f t h e
w i t h t h r e e . M a k e s u re t o u n c h e c k i t s t i c k
when clicked
t h e b a n a n a s , b u t d o ’nt r u n i t y e t a s y o u
s t i l l n e e d t o t e l l t h e c l o n e s w h a t t o do.
hide
set NumBananas
repeat
create clone of my s e l f
set color effect to pick random –10 to 20
show
change NumBananas by –1
if NumBananas = 0 then
broadcast GameOver
1 1 2 1
Yum y u m !
M a k e s u r e y o u r t re e i s s l i
behnidthetreandthegawmtork.
’ewon
or t o u c h i n g erT e 1
touching edge ?
repeat until
LaunchSpeed steps
move
E X P E R T T I P S
R u n t h e p r o j e c t T. h e m o n k e y s h o u l d
, “or , ” “ a n d ” “ n o t ”
41 s t o p f l y i n g w h e n h e h i t s t h e t r e e,
S o f ,a rm o s t o f t“ihf ethen”
blocks in this book have tested only a
r i g h t o f t h e t r e e i m p o s s i b l e t o re a c h .
s i n g l e c o n d i t i o n , s u c h “i af s t o u c h i n g c ai nt ”t h e S t a r H u n t e r g a m e .
Don’t w o r r, y gr a v i t y w i l l c o m e t o t h e
I n t h i s c h a p t ,e rh o w e v, e ry o u n e e d t o t e s t t wo c o n d i t i o n s a t o n c e :
rescue soon.
“ t o u c h i n g e d g e o r t o u c h .i nCegrToem1 p” l e x s e t s o f c o n d i t i o n s
like these occur a lot in coding, so you need a way to combine them.
I n S c r a t c h , t h e g re e n O p e r a t o r s b l o c k s d o t h e j ouboY.’ l l s e e words
, aa“ n“onnol,di“dktn”e” ra l m” o s t e v e r y p r o g r a m m i n g l a n g u a g e,
or
and
not
Logic blocks
L o g i c a l O p e r a to r s b l o c k s s u c h a s t h e s e t h r e e
go to Launcher
to “t wh eh e n
c l i c k ec odd”e .
go to Launcher
set Fa l l S p e e d to 0
or t o u c h i n g erT e 1
touching edge ?
repeat until
change y by FallS p e e d
change Fa l l S p e e d by Gravity
go to Launcher
“ G r, a vwi ht yi c h” m a k e s t h e m o n k e y
R u n t h e p r o j e c t a g a i n – y o u c a n n ow d i r e c t t h e m o n k e y o ve r t h e
t r e e t o r e a c h t h e t r i c k y l o w b a n a n a s . B u t h ow e x a c t l y i s t h e S c r a tch
61
t h a n t h e s e c o n d b e f o r e, c r e a t i n g a d ow n w a r d c u r ve.
Fall i n g f a s t e r
T“ahFl el S p e ev da ”r i a b l e m a k e s
t i m e tr“he ep e al ot o” p r u n s .
Fal l s t h i s f a r i n t h e
first second.
Fal l s t h i s f a r i n t h e
second second.
Fal l s t h i s f a r i n t h e
third second.
G r a v i t y e f fe c t
W h“aeFl nl S p e ei ds ”c o m b i n e d w i t h
thestraginhiletrofmth,heLaeuncher
m o n k es yp’ a t h c u r v e s b a c k t o w a r d s
t h e g r o u n d i n a r e a l i s t i c m a n n .e r
whe
set
hide
WELLDONE!
hide
whe
go
Leave a
gap here.
go t
show
sho
81
o f l a u n c h e s . C a l l t h i s v a r i a b“ Ll ea u, n schhoe ws ” i t o n
t h e s t a g e , a n d r i g h t - c l i c k ( i f y o ure’ u s i n g a m o u s e )
stop
o r l o n g - p r e s s ( i f y o u’re u s i n g a t a b l e t ) o n i t t o c h a n g e
i t “ tl oa r g e r e Ta. d ho ius t ”s h o w s j u s t t h e v a l u e a n d
n o t t h e n a m e o f t h e v a r i a bol eY. u ’ l l re p o s i t i o n t h e
l a u n c h c o u n t e r l a t .e r
R i g h t - c l i c k “ Lo anu n c h e s ”
on the stage. 02
Launches 0
normal readout
whe
large readout
cha
slider
S e l e“ cl at r g e
bro
r e .a d o u t ”
hide
T
SET L AU NCH SPEE DW I T H T H ESLI D E R
P R E S ST H E L AU N C H E R TO F I R E
WELL DONE!
oT m a k e t h e g a m e m o r e i n t e r e s t i n g , y o u c a n a d d s o m e s o u n d
e f f e c t s . Fol l o w t h e i n s t r u c t i o n s b e l o w t o p l ay d i f f e r e nt s o u n d s
S e l e c t t h e M o n k e y s prite, go to the
32
when I receive start launch
S o u n d s t a b , a n d l o“aBdoing”
from
t h e l i b r a rTh
. y e n a d sd“ taa r t s o u n d ”
i n t h e p o s i t i o n s h o w n h e r [Link] i s w i l l
m a k e t“hbeo i ns og ”u n d p l a y e v e r y
go to Launcher
24
“Chomp”
f r o m t h e s o u n d l i b r a r. y
hc“ o m p i ns go ”u n d w i l l p l a y e a c h
change NumBananas
s t a g e a n d s e l se“ clT.t i dh e r s”l i d e r l e t s y o u c h a n g e
Gravity
-0.2
Gravi
normal readout
large readout
slider
Select the
s “l i d e or p ”t i o n .
hide
E X P E R T T I P S
Displaying variables
uoY c a n c h a n g e h o w a v a r i a b l e i s
Shows
s h o w n o n t h e s t a g e The
. re are thre e
the name.
l a r g e r e a d o u t , a n d s l iodYe. r u c a n
b e s t f o r y o u r g a m e.
normal readout
large readout
slider
the value.
Shows just
the value.
A negative gravity value makes
t h e m o n k e y f a l l d o w n w a rd s , s o
i s c l o s e s t t o r e a l l i fe.
G A M E D E S I G N
Game physics
P h y s i c s i s t h e s c i e n ce o f f o r c e s a n d m o v e m e n t i n t h e
real world. G a m e p h y s i c s i s a l l a b o u t g e t t i n g t h a t
s c i e n c e i n t o g a m e s , s o t h a t t h i n g s r e a c t a n d m o ve
a r o u n d i n r e a l i s t i c w ay s – b e i n g p u l l e d d o w n b y
gravity, f o r i n s t a n c e , o r b o u n c i n g . P ro g r a m m e r s h a ve
m o r e r e a l i s t i c o r f u n .W h e n o b j e c t s c o l l i d e , s h o u l d t h e y
b o u n c e o r c r u n c h ? H o w s h o u l d o b j e c t s m o ve w h e n
G a m e p h y s i c s d o e s ’nt h a v e t o b e l i k e re a l - w o r l d
b o u n c e , u n t i l t h e y s h o o t o f f i nto space.
Try a d d i n g m o r e b a n a n a s , A d d m o r e f r u i t w i t h a d i f fe r e n t s c o re f o r e a c h
m a k i n g t h e m b i g g e r o r s m a l l ,e r t y op eY. u ’ l l n e e d to m a k e“ Score”
avariable
Fin,aladd
ly the two cod e b l o c k s o n the right to this sprite.
when
hide
when clicked
timer to 20.
set Ti m e L e f t to 20
variable is visible
on the stage.
repeat 20 w h e n I r e c e i v e sTime’
Up
wait 1 seconds go to x: 0 y
change Ti m e L e f t by –1 go to front
show
l o u d n o i s e . R e m e m b, e Sr c r a t c h i s o n l y
l i s t e n i n g f o r n o i s e s, i t i s ’ nt re c o r d i n g yo u .
Danger! Snake!
i n t h e m o n k es yw’ a y o r m a y b e
▽
Bug or bonus?
m o n k es ys ’p e e d i n f l i g h t w i t h t h e L a u n c h S p e e d
s ol i dY.e r u c a n f i x t h i s b y a d d i n g a n e w v a r i a b l e ,
“ M o n k e y S, paenedd c” o p y i n g t h e v a l u e o f
“ L a u n c h S p e ei nd t” o i t a t l a u n c hT. h e n u s e
M o n k e y S p e e d , n o t L a u n c h S p e e d , i n t h e m o ve
Launch speed s
c h a n g e t h e m o n k es ys ’p e e d , l e a v e t h e g a m e a s i t i s .
uoY’ v e a l re a d y t r i e d a d d i n g a s l i d e r t o
c o n t r o l g r a v i t . yoY u c o u l d a l s o a d d a
Gravity
LaunchSpeed
D o o m o n
t h e B r o o m
with animation.
A I M O F T H E G A M E
t h e w o o d s w h e n c r e a t u re s o f t h e n i g h t
b e g i n t o a d v a n c e o n h e r f ro m a l l s i d e s .
t h a t h a v e t a k e n a f a n c y t o h e r f o r d i n n e. r
◁ Witch
T h e w i t c h s i t s i n t h e c e n t re o f t h e
y o u r c o m p u t e r m o u s e o r y o ur
f i n g e r ( i f y o ure’ u s i n g a t a b l e t ) a n d
◁ Enemies
E v e r y e n e m y h i t b y a f i re b a l l i s
speeds up.
◁ Lives
EXTRA
touched by any of her enemies.
LIFE
c e n t r e o f t h e s t a g e.
The costume will appear as a sprite in the
sprites list.
L o a d t h e s o u“Cave”
nf rdo m t h e s o u n d
G o t o t“Ch he o o s e a B a c k d r o ”p symbol
2 3
l i b r a r y a n d a d d t h i s c o d e t o t h e s t sa g e’
a n d a d d t h e b a c k d r“o. ThpWiosods”
will lend
t h e s p o o k y a t m o s p h e r e y o u’ve created.
the theme.
when c l i c ke d
forever
when c l i c ke d
t i m e si t r u’ n .
forever
159 x 120
a“nbat-b”
d– for this game.
bat-b
101 x 105
G A M E D E S I G N
Animation
ouY c a n m a k e p i c t u r e s a p p e a r t o m o ve b y a l l c a r t o o n s w o r k . S c r at c h l e t s y o u a n i m a te a
s a m e p i c t u r e o n e a f t e r a n o t h [Link] i s f o o l s t h e i t i n d i f f e r e n t poses. Wh e n t h e s e c o s t u m e s a p p e a r
b r a i n i n t o t h i n k i n g t h a t i t i s a s i n g l e m ov i n g o n e a f t e r t h e o t h e, r y o u c a n s e e f l a p p i n g b a t s ,
i m a g e .T h i s i s c a l l e d a n i m a t i o n , a n d i t i s h o w w a l k i n g c a t s , a n d j u m p i n g f ro g s .
game and the
W i t c h s p r i t e.
continually checks on
▷
t h e m o u s e - pointer
T h e v a r i a b“ lGea m e S p e e d ”
c o n t r o l s t h e o ve r a l l p a c e o f
t h e g a m e . oF r n o w f i x i t at 1.
Later
, you’l find out how to
increase it as t h e s c o r e rises,
Casting fireballs
The witch’
s o n l y d e f e n c e a g a i n s t t h e r a m p a ging
s p o o k s w i l l b e h e r f i r e b a l l s p e l l The
. next bit of code
w i l l m a k e a f i r e b a l l s h o o t f r o m h e r b ro o m s t i c k w h e n
Rename the
9 sprite here.
f r o m t h e l i b r a r y and
r e n a m e“Fii tr. e b a l l ”
Sprite iFr e b a l l
I s t c’ u r r e n t l y t o o b i g,
but you’ l l s h r i n k i t
Show
down in a moment.
t h e s p r i t e s l i b r a r. y
Choose a Sprite
Witch
move 10 steps
when clicked
set size to 10 %
hide
1 1
f i r e b a l l s p e l l W. h e n t h e b u t t o n i s p r e s s e d i t w i l l
b r o a d c a s t a m e s s a g e n a ms“e tda r t .s pG eo l tl o” t h e
Lives
Score
“, S ap ne dl l p” l a c e i t o n t h e b o t t o m r i g h t o f t h e s t a g e.
T h e n a d d t h e f o l l o w i n g c o d e t o t h e S p e l l s p r i t e.
O p e n t h e d r o p - d own
m e s s a g e c a ls “ltea dr t. s p e l l ”
2 1
the Fi r e b a l l s p r i t e w h e n t h e S p e l l s p r i t e i s p r e s s e d .
w h e n I r e c e i ve start spell
E v e r y t i m e t h e b u t t o n i s p r e s s e d a m a g i c s t re a m o f
f i r e b a l l s w i l l s h o o t o u t o f t h e w is t c ’h b r o o mT. h e r e w i l l
repeat 50
b e 5 0 f i r e b a l l s s h o t o u t o v e r 5 s e c o n d rsT. y t h e c o de
a n d c h e c k i f y o u c a n s p i n t h e w i t c h a n d s h o o t f i r e balls.
create clone of Fi r e b a l l
These blocks
create clone of my s e l f
go to x: 0 y: 0
move 300 s te p s
show
p o i n t t o w a r d s Wit c h
touching Wit c h ?
repeat until
touching Fireball ?
if then
change Score by 1
L o a d t h e s o u“ noPp”d
f r o m t h e s o u n d l i b r a r. y
broadcast L o s e a l i fe
G o t o t h e d r o p - down menu,
s e l e“ Nc te w m, e as snadg e ”
n a m e t h e m e s s a“ gLoes. e a l i fe”
R u n t h e p r o j e c t t o s e e i f i t wo r k s . A b a t s h o u l d
I s t a’ g o o d i d e a t o r e m o ve a l l t h e b a t s w h e n e v e r
41 5 1
t o r e c o v e r b e f o r e t h e n e x t w a v e o f a t t a c k e r s. t o w a r d s t h e w i t c h . S o o n m o r e w i l l a p p e .a r
T h e w i t c h s h o u l d b e a b l e t o u s e h e r f i re b a l l s
A d d t h i s c o d e t o t h e b a t t o d o t h e j o b . Whe n
w h e n I r e c e i ve L o s e a l ife
uoY m i g h t n o t i c e t h a t t h e b a t s a r e n’t f l a p p i n g
61
a n y m o r eoT. f i x t h i s , a d j u s t t h e c o d e b e l o w
s o t h a t i t r u n s f o r e a c h c l o n e r at h e r t h a n j u s t
forever
t h e s t a r t of the code.
A d d t h i s c o d e t o t h e w i tc h t o m a k e
7 1
h e r r e a c t t o l o s i n g a l i fe . I f s h e s t i l l
w h e n I r e c e i ve L o s e a l ife
hide
b a t t l e . I f s h e’ o u t o f l i v e s , t h e n si t ’
g a m e o v.e rA d d a n e w m e s s a g e ,
“ G a m e O, vweh ri c h” y o u ’ l l n e e d l a t e r
i n t h e p r o j e c t . N o w t r y t h e g a me change Lives
again. Th e w i t c h s h o u l d l o s e l i v e s
Lives > 0
if
“ L i vve as ”r i a b l e h a s a v a l u e o f 0 .
wait 2 seconds
show
else
broadcast GameOver
wait 1 seconds
T“ hG ea m e O ve r ” message
stop all
you’ll c r e a t e l a t. e r
oT c r e a t e f i r e wo r k s y o u n e e d a n e w s p r i te. Load
81
a n o t h e r B a l l s p r i t e f r o m t h e s p r i t e s l i b r a r y rather
s p r “i tE ex p l o s i oa n ”d t h e n c l i c k o n t h e C o s t u m e s
tab. Sel e c t t h e s e c o n d c o s t u m e s o t h a t t h e b a l l
turns blue.
show
set size to 5 %
repeat 72
repeat until
turn 5 degrees
move 10 steps
create clone of my s e l f
hide
i n a d i f f e r e nt d i r e c t i o n .
02
r e c e i v e s t h e m e s s a“gL eo s, e a l i f e”
a t t h e w i tsc hl ’o c a t i o n a n d
Score 0
s t a g e b e f o r e h i d i n g o n ce a g a i n .
bat-a
143 x 91
make Fa s t g r i f f i n l o o k t w o d i f f e re n t p o s i t i o n s .
bat-b
101 x 105
at the bottom left of costume you want to
new costumes.
oT s p e e d u p t h e f a s t g r i f f i n ,
24
GameSpeed
move
c h a n g e m“i tbove”
sl o c k t o m a k e
touching Wit c h ?
repeat until
touching Fireball ?
if then
change Score by 1
wait 20 seconds
forever
7 + 2
7 – 2
9 5
create clone of my s e l f
7 2
7 / 2
*
14 3.5
C h e c k y o u h a v e f o u r c o d e b l o c k s i n a Fs t
Code Costumes
griffin’
s c o d e a r e a , j u s t l i k e i n B a t. Run the
62
Motion
Motion
g a m e . A f t e r a f e w b l a c k b a t s h a ve a t t a c k e d ,
move 10 steps
a f a s t ,e rm u c h m o r e d a n g e r o u s g r i f f i n w i l l Looks
turn 15 degrees
a p p e ,a rf l a p p i n g a w a. y
turn 15 degrees
Sound
Events
go to random position
go to x: 0 y: 0
Control
Sensing
glide 1 secs to x: 0 y: 0
Operators
point in direction 90
Vari a b l e s
My Blocks
c o s t u m“ De sr a g o n 1 - a ” and
“ D r a g, otnh1e- nb ” d e l e t e
Dragon
forever
Type t h e
n e w s p r si t e ’
name here.
x
Sprite Dragon 20
wait 2 seconds
Dragon
N e x t , m o d i f y t h e d r a g so ’n
92 repeat until
touching Wit c h
p o i n t t o w a r d s Wit c h
“ p o i n t t owards Witch”
block
i n t o tr“eh pe e a t u n t i l ”
turn 80 degrees
l o o p a n d a d d i n g“ t au r n
r i g h t 8 0 d e g r e e s” block.
move GameSpeed
touching Fireball
if
change Score by 1
In Doom on the Broom, spooky scenery and the elements of a game can make it feel polished
supernatural characters work together to give the and professionalWo. r k ing with themes is also great
game a theme. A strong theme that ties together fun as you can let your imagination run wild.
Story
[Link] the player is trying to escape a haunted Sounds in a game have a big influence on how the
house, searchof r underwater treasure,or explore an player feels. Spooky music makes the playe r n e r v ous,
Goldilocks and the three bears in space. they match the sprite or situation that triggers them.
△ △
Scenery Sprites
w i l l l o o k l i k e t h e y a r e r e a l l y t h e re r a t h e r t h a n s t u c k o n a l i k a b l e s p r i t e T. h e e n e m i e s d o n ’t h a v e t o l o o k
top.
uoY c a n c r e a t e y o u r o w n b a c k d r o p s i n S c r as tch’ scary – even cute sprites can seem scary when they
f o u n d o r c r e a te d e l s e w h e r e . l o o k v a l u a b l e , s u c h a s c o i n s o r g e m s.
a“ nG. dh o s t - ”b
Ghost2-a
143 x 142
C h a n g e t h e g h o ss tc’o d e s o t h a t i t m o v e s s l o w l y a n d f a d e s o u t
33
p a l e t t e a n d l o a d t“hS ecreech”
s o u n d f r o m t h e s o u n d l i b r a r. y
t o m a k e t h e g h o s t s c r e a m w h e n i t v a n i s h e s.
touching Wit c h ?
repeat until
move 1 steps
m“ toov e . 1 s t e p s ”
touching Fireball ?
if then
repeat 100
This makes
change Score by 1
53
t e s t t h e g a m reT. y
fireballing each
Score 30
The ghost
should slowly
with a fireball.
63
Costume
costume1
73
s p r i t e i n t h e p a i n t e d i t .o rU s i n g
Fill Outline
“Conver t t o ,B di tr map”
aw a
c o l o .u rN o w s w i t c h “Cot on v e r t
r e d f o r t h e te x t c o l o .u rC l i c k i n
t h e r e c t a n g l e a n d t y“Gp AME
e
O V E aR n! ”d u s e t h e s e l e c t i o n
t o o l t o m a k e t h e t e x t l a rge.
Type “GAME
O V EhRere.
!”
Convert to Bitmap
N o w a d d t h e s e c o d e b l o c k s t o t h e n e w s p r i t e to
83
when
when the witch loses all her lives. Run the game.
O n c e t h e w i t c h l o s e s a l l h e r l i v e s, t h e m e s s a g e
hide
w i l l b e d i s p l a y e d o n t h e s t a g e.
go to x:
Rename
GAME
the sprite
OVER!
“ G a m e .O v e r ”
wait 1 seconds
Game Over
show
Challenger mode
40
scores points, a
m o r e p o i n t s , t h e y m ay s t a r t t o g e t b o r e d
movement loop
w i t h t h e g a m euoY. c a n p r e v e n t t h i s by
variable using
m a k i n g t h e g a m e f a s t e r a s i t p r o g re s s e s .
when c l i c ke d
set GameSpeed to 1
set Score to 0
set Lives to 3
set size to 35 %
go to x: 0 y: 0
point in direction 90
show
W h e n t h e s c o r e i s 0 , G a m e S p e e d i s 1 W. h e n t h e
forever
s p e e d u p s o o n. e r
42
w h e n y o u f i r e b a l l t h e h i p p o, y o u e a r n a n e x t r a l i f e w h e n
i t t o u c h e s y o u . C h a n g e t h e v a l u e i n tp“hoei n t i n d i r e c t i o ”n
b l o c k s o t h e t e x t o n t h e h i p p o d o e s ’nt g e t r e v e r s e d .
Change this
v. a l u e“ 0to”
move 300 s te p s
show
p o i n t t o w a r d s Wit c h
touching Wit c h ?
repeat until
touching Fireball ?
if then
change Lives by 1
l i f e t o t h eWitc h s p rsi t e ’
l i v e s c o u n t. e r
skcaH t kdna ae w s
N o w t h a t y o u’ve go t y o u r g a m e
m a k e i t y o u r o w n by c h a n g i n g
a n d a d d i n g e l e m e n t sr T. y t h e s e
s u g g e s t i o n s t o g e t s t a r t e d.
FlyingWi t c h
uoY c a n m a k e t h e w i t c h f l y
when clicked
forever
spot by adding the code
s h o w n h e r eoT. m a k e h e r
move 1 steps
“hteurr n ” blocks.
A I M O F T H E G A M E
T h e d o g l i k e s b o n e s b u t h a t e s j u n k f o od.
f r o m p l a t f o r m t o p l a t f o r m . Co l l e c t a l l
g o t h r o u g h t h e p o r t a l t o t h e n e x t l e v e l.
c a k e s , c h e e s y p u f f s, a n d d o n u t s !
Dog
U s e t h e l e f t a n d r i g h t a r r ow k e y s o r
Bones
uoY n e e d t o c o l l e c t a l l t h e
b o n e s t o o p e n t h e p o r t al to
s h u t u n t i l y o u ’v e g o t t h e m a l l .
Junk food
I f t h e d o g t o u c h e s a n y j u n k food,
is t g’ a m e o v e r a n d y o u h a v e t o
s t a r t a g a i n on Level 1 – no matter
s p r i t e s m e n u . M a k e s u r e y o u s e l e“Coc tn v e r t t o B. i t m a p ”
C h o o s e r e d f r o m t h e c o l o u r p a l e t t e i n t h e p a i n t e d i t ,o rs e l e c t
Select the
Paint
Code
you’re u s i n g a t a b l e t ) , a n d d r a g o ve r
t h e p a i n t i n g a r e a t o d r aw a s m a l l r e d
s q u a r e . O n a c o m p u ter, h o l d i n g d o w n
r a t h e r t h a n a r e c t a n g l e. I f y o u c l i c k
costume1
35 x 35
be smaller than
t h e c sa tf a’ c e o n
the stage.
to resize the block.
t o c r e a t e a n e w s p r i t e . U s e t h e re c t a n g l e t o o l
t o d r a w a f l o o r w i t h t wo o b s t a c l e b l o c k s o n
t h e o b s t a c l e s , b u t m a k e s u r e s i tn’ o t t o u c h i n g
the platform.
T“ hPle a y e r B l o cs kp ”r i t e c a n b e m o v e d u s i n g
6
t h e k e y b o a r d a r r o ws , o r ( i f y o u’re p l a y i n g o n
when clicked
s c r e e n . A d d t h e B u t to n 1 s p r i t e f r o m t h e
go to x: –200 y: –145
set ghost
f o l l o w t h e i n s t r u c t i o n s gi v e n i n s t e p 4 a n d
5 o f C h e e s e C h a s e ( s e e p p . 52–53). Th e n
forever
m a k e t h e b u t t o n a l w a y s p o i n t towards the
hide
d i r e c t i o n o f y o u r f i n g .e r
point in direction 1
if
show
“ G a .m e p a d ”
Gamepad
Code tab and choose My Blocks.
of your new
block here.
Code
Sounds
Costumes
My Blocks
Motion
Make a Block
Looks
Sound
Events
Control
Sensing
Operators
Vari a b l e s
Make a Block
My Blocks
Run controls
L I N G O
Subprograms
S c r a t c h l e t s y o u gr o u p t o g e t h e r b l o c k s u n d de r“ a efine”
header
b l o c k a n d r u n t h e m b y u s i n g a n e w b l o c k t h a t y o u n a m [Link]
saves you buil ding the same group of blocks again if yo u want to
u s e i t i n m o r e t h a n o n e p l a c e . (However
, the new block will only
w o r k w i t h t h e s p r i t e t h a t yo u c r e a t e d i t for. ) G i v i n g y o u r n e w b l o c k
a m e a n i n g f u l n a m e w i l l m a k e y o u r c o d e e a s y t o u n d e r s t a n d. M o s t
p r o g r a m m i n g l a n g u a g e s l e t yo u t a k e s o m e u s e f u l c o d e , g i v e i t a
n a m e , a n d w r a p i t u p a s a u n i t . D i f fe r e n t l a n g u a g e s c a l l t h e s e u n i t s
d i f f e r e n t t h i n g s : s u b p r o g r a m s , s u b r o u t i n e s , p ro c e d u r e s , and
I n t h e aV r i a b l e s s e c t i o n ,
01
s p r i t e s c a l l“eRdu n S p e e d ”
player moves l e f t a n d
if
s o i t d o e s n ’t a p p e a r o n t h e
s t a g eT. h e n b u i l d t h e c o d e
change x by 0 –
ed“ fine”
h e a d .e rA n y w h e r e
touching Platforms
w e u s e t“hReu n c o n t r o l s ” if
change x by RunSpeed
in a similar way to
t h e r i g h t c o n t r o l.
N o w r u n t h e p r o j e cuotY. s h o u l d b e a b l e t o
Next, add the code below
2 1
1 1
move the red block left and right with the
to use your new custom
a r r o w k e y s o r t h e g a m e p a d, b u t n o t b e a b l e
b l o c k i n“ f ao r e v loop.
er”
when clicked
set RunSpeed to 5
forever
Run controls
define S i m u l a t e g r av i t y
change y by FallS p e e d
change y by FallS p e e d
0 –
set Fa l l S p e e d to 0
else
change Fa l l S p e e d by
Gravity
uoY n e e d t o
of gravity!
I n s e r t the blocks
41
P l a y e r B l o sc km’ a i n
“ G r a v i t“ y–tao1n ”d
s e t a Fl l S p .e e d “ 0to”
“set Fa l l s p e e d hteor ”e .
“PSui tm u l a t e gr a v i t y ”
i n t o “t fh oe r e vloop.
er”
Nerounwsiocetgryuaohetjm
u’fIp.
61
acompuetarndkeyboujas,add
drt
somenewcodeotgviethePalyeBrolck
anupwardkcikwhenoyupresthe
tsrmake
i.F, spanew
cebarvaraible
key space
if
T . his akeof“fSpeed”Tsofpaltericseald
supwsiathdrspepleeadyeronuaj’m
.p
set Fa l l S p e e d
J Th“enceraetnewbolckcaeldump
[Link]”tl
o T maketheujmpworkonatblet
a lwldde’somecodenithenextsection
s(tep21and22).
I n s se“ar etktTe o f f S p e e d t o “ h e r e .
when c l i c ke d
A d d st“ haetekTe o f f S p e e d t o ”
7 1
b l o c k i n t o t h e P l a ye r B l o cs k ’
set a keT o f f S p e e d to 12
m a i n c o d e a n d s e t . i t “ t1o2 ”
I n s e r Jt t“h e u m p c o n t r o l ”
set RunSpeed to 5
b l o c k i n t o t“hf eo r e v loop.
er”
set Gravit y to –1
set Fa l l S p e e d to 0
What happened
there?
forever
Run controls
Jump control
J u m“ pP u t
c o n t ri on lt ”o t h e
Simulate grav i t y
“ f o r e vloop.
er”
T h e r e a r e t wo b u g s t h a t s p o i l o u r j u m p s : o n e
c a u s e s t h e P l a y e r B l o c k to j u m p i n f i n i t e l y h i g h ;
t h e o t h e r s t o p s i t f a l l i n g s m o o t oh lY.y u c a n f i x
t h e m b y t w e a k i n g t h e j u m p a n d g r a v i t y c o ntrols.
P l a y e r B l o c k d o w n o ne step.
change y by –1
touching Platforms ?
if
then
set Fa l l S p e e d to
kaTe o f f S p e e d
change y by 1
s m a l l d o w n w a r d step.
Try t h e c o d e a b o v e a n d yo u ’ l l f i n d y o u
20
p l a t f o r m a n d c a ’nt l e a p h i g h e r b y t a p p i n g
show
P l a y e r B l o c k s p r i t eT. h i s
change y by –1
e a r l i .e rN o w w h e n y o u p r e ss
if touching Platforms
i t w i l l m a k e t h e P l a y e r B l o ck
set Fa l l S p e e d to
jump up.
change y by 1
jump only when it
touches a platform.
if touching Platforms
n e g a t i v“ eR )e, v e r s e S tep”
is set to +1 (up).
if FallS p e e d
If the PlayerBlock is
set R e v e r s e S te p to 1
r i s i n g o r s t a t i o n a r, y
“ R e v e r s e S t e ”p is set
else
to –1 (down).
set R e v e r s e S te p to –1
r e v e r s e s b y 1 step.
change y by ReverseStep
set Fa l l S p e e d to 0
How it works
else
p l a t f o r m , tr“eh pe e a t u n t i l ”
change Fa l l S p e e d by
u n t i l i t s i t s j u s t o n e s t e p a b o ve
the platform.
T“ hMe a k e a B l o cbox
k”
52
a p p e a r s a g a i Tin“ cR. ku n
w i t h o u t s c r e e n . r e f resh” Th i s
w i l l m a k e t h e g r a v i t y c o de
s l o w - m o t i o n e f f e c t.
Add an input Ad d a n i n p u t
T i c k t h i s b o x to
number or text
r u n m u c h f a s t. e r
R u n w i t h o u t s c r e e n r e f re s h
N o w t r y j u m p i n g a g a i n . Th e t w e a k s
62
you’ve ma d e s h o u l d h e l p t h e P l a y e r B l o c k
t o j u m p a n d l a n d v e r y smoothly.
stage. Add it to the
s t e e r l e f t a n d r i g h t d u r i n g t h e j u m p.
b u i l d t h e s h o r t bit of
g e t s t“hGea m e O v e r ”
m e s s a eg seTt. t he
Double jump
controls should
T h i s i s t h e j u m p y o u h a d b e f o re you
f i x e d t h e i n f i n i t e j u m p i n g b u g – you
c a n j u m p a g a i n i n t h e a i r t o g o h i g h .e r
d o u b l e j u m p i n g – f o r e x a m p l e , you
“ tf ho er e v e r ” bl o c k .
c a n o n l y d o i t i f y o ure’ g o i n g u p .
define Fa l l e n o f f
if y position
Wall j u m p
broadcast GameOver
W h e n y o u t o u c h a w a l l, y o u c a n j u m p
h a v e t h i s p o we.r Is t n’ o t v e r y r e a l i s t i c
b u t ist l ’o t s o f f u n !
when c l i c ke d
a t t h e s t a r t.
set size to 50 %
point in direction 90
g “T h ebo lto”o c k p l a c e s t h e
d o g o n t h e r e d s q u a r e.
show
forever
o f t h e r e d s q u a r e.
go to Playe r B l o c k
go to front laye r
if then
l e f t a r r o w k e y i s p re s s e d .
next costume
if then
point in direction 90
next costume
n“T he xe t c o s t u mb leo” c k s
a n i m a t e t h e dso gw’ a l k .
Collision detection
Bumper sprites
Collision detection – knowing when and how
c h a l l e n g e w h e n b u i l d i n g g a m e s Thi
. s book sprites that move with it and detect collisions in
e a c h d i r e c t i o n . K n o w i n g w h i c h d i r e c t i o n y o u’ve
m o s t l y u s e s s i m p l e c o l l i s i o n d e t e c t i o n , b u t Dso g’
c o r r e c t l. y E x t r a s p r i t e s
s p r i t e i s t o u c h i n g a h a z a r d. Is t f ’i n e f o r s i m p l e
type of detection.
g a m e s , b u t w i t h o u t e x t r a c o d e y o u d o n ’t k n o w
h o w m u c h i s o v e r l a p p i n g.
UB
M
!P
c o s t u m e s , c r e at i n g
false collisions.
c l e v e r m a t h s y o u c a n wo r k
Collision-detection sprite
h i t e a c h o t h .e rB u t b e
U s i n g a s i m p l e r e c t a n g l e w i t h a n a n i m a te d s p r i t e
r e a l l y c o m p l i c a t e d,
P l a y e r B l o c k i s a l w ay s t h e s a m e s h a p e
a n d s i z e . B u t yo u s t i l l d o ’nt
UB
M
!P
if sqrt((dogx–jellyx)^2+(dogy–jellyy)^2) <
t o u c h e d . P ro g r a m m i n g t r i c k s
s o l v e s o m e o f t h e p r o b l e m s.
Delete the dog2-a and
A d d t h e s e t w o co d e b l o c k s t o
33
when c l i c ke d
when I receive GameOver
hide
go to Playe r B l o c k
set size to 50 %
go to front laye r
show
43
Here we go a g a i n !
hide
Y
0 0
0 0
2 1
– –
oT h e l p s h o w w h e r e t h e p l a t fo r m s g o , t h i s i m a g e i n c l u d e s S c r a tsc ’ h
x y - g roi [Link] e e t h e g r i d w h e n y o u d r aw t h e p l a t f o r m s, s e l e c t t h e s t a g e
i n f o a r e a i n t h e l ow e r r i g h t a n d c h o o s e t h e b a c k d ro p s y m b o l
o p e n t h e b a c k d r o p l i b r a r. y S c r o l l t o t h e e n d a n d c h o o“ Xs .ey -I gt r i d ”
isn’t e s s e n t i a l t o d o t h i s, b u t y o u m i g h t f i n d i t h a n d yYo. u c a n r e p l a c e
t h e x y - g r i d w i t h c o l o u r b a c k g r o u n d s a f te r y o u ’v e m a d e t h e p l a t f o r m s .
0 0
0 0
2 1
– –
▷ Level 3
O n t h e l a s t l e v e l , s o m e p l ay e r s w i l l
d o n u t , b u t si ta’ t r a p ! Ist m’ u c h
d o n u t a l t o g e t h .e r
0 0
0 0
2 1
– –
the sprite on the stage so that platforms will appear
switch costume to
W i t h t h e P l a t fo r m s s p r i t e s e l e c te d , c h o o s e t h e C o s t u m e s t a b a n d
63
t h e n u s e t h e p a i n t b r u s h s y m b o l i n t h e c o s t u m e s m e n u t o c r e ate
t h r e e n e w c o s t u m e s . D e l e t e t h e o l d t e s t p l a t f o r m c o s t u m eT. h e n
u s e t h e r e c t a n g l e t o o l t o d r a w t h e p l a t f o r m s o n e a c h l e v erlT. y to
m a t c h t h e p i c t u r e s o n t h e p re v i o u s p a g e s . D o ’nt wo r r y a b o u t
g e t t i n g t h e m p e r fe c t , a s y o u c a n a d j u s t t h e m l a t .e r
Costume Level 1
Fill
Filled Outlined
Level 1
397 x 230
Select solid
c o l o. u r
Use the
rectangle tool.
T“ hS ee l e c t ” to o l
and move a
platform.
Make sure
you’re i n
“ B i t m a p. M o d e ”
Convert t o V e c to r
Convert t o Vecto r
t h e c o r r e c t o r d e r h euroeY . c a n d r a g
a n d d r o p t h e m t o c h a n g e t h e o r d. re
Costume Level 2
Fill
Level 1
Outlined
Filled
397 x 230
Level 2
313 x 360
Level 3
480 x 279
Convert t o Vecto r
f o l l o w i n g c o d e. Is t a’ l o o p t h a t r e p e a t s fo r e v e r y l e ov e Yl . u
a l s o n e e d t o m a k e t w o n e w m e s s a g e“ Ss t: a r. at“n ”dWi ”n
when c l i c ke d
set Leve l to 1
Level = 4
repeat until
set Bones to 0
broadcast Start
LevelOve r = 1
wait until
change Level by 1
b r o a d c a s t Win
t“ h emWi ”en s s a g e i s s e n t .
How it works
T hs awt h’ a t h a p p e n s
This code goes once round the loop for each level
o f t h e g a m eT. h e n i t m o v e s o n t o t h e n e x t b l o c k ,
w h i c h b r o a d c a s t “s aWim ”ne s s a g e t o s a y t h a t t h e
p l a y e r h a s w o n Th
. e first broadcast is the message
,“ Swe ht ui pc ”h g e t s t h e s p r i t e s a n d b a c k g r o u n d i n
m o v i n g o n T. h e n t“hSet a r mt e” s s a g e i s s e n t T. h i s
t r i g g e r s a l l t h e w o r k i n g c o d e b l o c k s f o r t h e l e vel,
w h i c h m o v e t h e s p r i t e s a n d l o o k o u t f o r c o l l i s i o n s.
set RunSpeed to 5
Swap the
set Gravit y to –1
green flag
if
header for
t“ hw eh e n I
set Fa l l S p e e d to 0
go to x: –120 y: 135
receive Start ”
message.
forever
Run controls
if
Jump control
go to x: 20 y: 180
Simulate grav i t y
Fall e n o f f
if
uoY a l s o n e e d t o c h a n g e D o sg 2c’o d e s o
go to x: –30 y: 140
14
t h a t si tt ’r i g g e r e d b y t“hS et a r mt e”s s a g e .
w h e n I r e c e i ve Start
when c l i c ke d
set size to 50 %
point in direction 90
show
forever
go to Playe r B l o c k
l i s t t o o p e n t h e s p r i t e s l i b r a r. y Ad d B u t t o n 1 t o
y o u r g a m e a n d c h a n g e i t s n a m e “ tPo.o r t a l ”
T h e p o r t a l n e e d s s o “mS eetup”
code to position
“ L e v e l O ve i sr s” e t t o 0 t o
43
i t c o r r e c t l y i n e a c h l e ve l a n d t o m a k e i t s l i g h t l y
s e e - t h r o u g h b e f o r e i t o p e n s.
over because the bones
haven’t b e e n c o l l e c t e d.
g h “Toh se t ” b l ock
m a k e s t h e p o r t al
Level
if = 1 then
go to x: 200 y: –40
Level then
if = 2
go to x: 100 y: –150
Level
if = 3 then
go to x: 175 y: –125
touching Player B l o c k
repeat until
S e t t “i nL eg v e l O ve r ”
to 1 triggers a
change of level.
L I N G O
Flags
“ L e v e l O ve ir s ” a v a r i a b l e t h a t t h e p o r t as l code
’
l e v e l i s c o m p l e t e. ( R e m e m b e r t h“ we a i t u n t i l ”
b l o c k i n t h e G a m e C o n t r o l sprite’
s loop? It
m a k e s t h e c o d e w a i t b e f o re s w i t c h i n g t o t h e
n e w l e v e“l L. )e v e l O ve ar l ”l o w s d i f f e re n t p a r t s
o f a p r o g r a m t o c o m municate. Pro g r a m m e r s
c a l l a v a r i a b l e u s e d i n t h i s w a ,y“ aflag”
an d i t
W h “eLne v e l O ve ir s ” 0 ( b e c a u s e t h e l e v e l i s n’t
o v e r ) , w e s ay t h a t t h e f l a g i s u n s e t .W h e n
“ L e v e l O ve ir s ” 1 ( b e c a u s e t h e p l a y e r h a s
f l a g i s s e t . M e s s a g e s c a n o n l y s t a r t code
b l o c k s , b u t b y u s i n g a f l a g yo u c a n p a u s e t h e
I n t h e G a m e C o n t r o l sprite’
s l o o p , t “h wait
e
u n t bi l l”o c k p a u s e s u n t i l t h e f l a g e q u a l s 1 .
T h e x a n d y c o o r d i n a tes
change Bones by 1
Level
if = 1
t h e g a m eT. h e p o s i t i o n s
go to x: –175 y: –95
platform designs
exactly, b u t t h e y ’ l l b e
f i n e f o r n o .w
Level
if = 2
go to x: –30 y: –110
if Level
= 3
go to x: –150 y: –65
show
w h e n I r e c e i ve Start
74
hide
change Bones by –1
The number of
falls by 1.
uoY n e e d t o c h a n g e t“hS eetup”
co d e
B O N E 3
94
a p p e a r i n d i f f e r e nt p l a c e s t o B o n e 1 o n
og“b to”
l o c k s t o m a t c h t h o s e s h o w n h e re.
change Bones
B O N E 2
if
go to x: 35 y: –70
change Bones by 1
Level then
if = 1
if
go to x: –10 y: 105
go to x: 60 y: –60
Level then
if = 2
if
go to x: –10 y: 80
go to x: 120 y: 140
show
Level then
if = 3
go to x: 0 y: 15
05
show
repeat 35
Level then
if = 1
go to x: 140 y: 35
point in direction –
if Level then
= 2
repeat 35
go to x: 0 y: 15
Level then
if = 3
go to x: 70 y: 30
54
w h e n I r e c e i ve Start
broadcast GameOver
broadcast GameOver
uoY n e e d t h r e e c o s t u m e s f o r t h e H a z a r d s
75
s p r i t e . G o “Ct ho o o s e a C o s t u ma te ”t h e l o w e r
l e f t o f t h e w i n d o w a n d s e l e“Ccht e e s y P u f f s”
a s t h e f i r s t c o s t u m e . S e l e c t t h i s b u t to n t w i c e
m o r e t o a d d t “Ca
w o k e s -p”ar i t e s a s t h e
s e c o n d a n d t h i r d c o s t u m e s. D ec l e“ t eo s t u m e 1 ”
t h e m a s s h o w n h e r eoY. u c a n f i n e - t u n e t h e i r
p o s i t i o n s l a t .e r
Use a bowl of
cheesy puffs
in Level 1.
f o r a s e e - t h r o u g h c o l o. u r
in Level 2. in Level 3.
P l a t f o r m s s p r i t e a n d g o t o t h e C o s t u m e s t a b.
U s e t“hS ee l e ct to o” l i n t h e p a i n t e d i t o r t o
m o v e , s t r e t c h , o r r e s i z e t h e Le v e l 1 p l a t fo r m s .
C l i c k o u t s i d e t h e s e l e c t i o n b o x t o s h ow y o u r
95
p o s i t i o n o f t h e H a z a r d s s p r i t e. S e l e c t i t i n t h e
t“hS ee l e ct to ”o l t o a d j u s t t h e p o s i t i o n o f t h e
cheesy puffs
Level 1). Click outside the selection box to
using the
“ S e l e ct ot o”l .
uoY c a n r e p o s i t i o n a l l t h e
60
b l o c k i n t h e s p r ist eL’e v e l 1 c
if
go to x: 35 y: –70
x y
Sprite Sprite1 35 -70
T h e b os n en ’e w
c o o r d i n a t e sa p p e a r
automatically in
b e a r i n m i n d t h a tg t“h e obto”
lock sets on another level and its sprites, you can make a temporary
16 62
i t s s t a r t p o s i t i o no. Tc h a n g e h o w f a r i t change to the code for the Game Control sprite. Change
“ r e p e laot o” p s . O n e c o n t r o l s h o w f a r i t a n d L e v e l 2 a p p e a r s o n t h e s t a g e . Fi n e - t u n e y o u r s p r i t e s’
g o e s t o t h e r i g h t , t h e o t h e r t o t h e l e f t. p o s i t i o n s . B u t r e m e m b e r t o c h a n g e t h e n u m b e rs“ i et
n
Levelbto”
a c k “wt1ho”e n y o ur e’ d o n e .
w h e n I r e c e i ve Start
when c l i c ke d
forever
set Leve l to 1
point in direction 90
repeat until
repeat 35
set Bones
move 3 steps
Moves
donut
broadcast Setup
right
broadcast Start
wait until
repeat 35
move 3 steps
change Score
Moves
donut
left
b r o a d c a s t Win
t h r e e c o d e b l o c k s b e l o .w R u n t h e p r o j e c t t o
c h e c k t h a t t h e c o r r e c t s i gn s s h o w a s y o u p l ay.
when c l i c ke d
T O O P E N P OARLTO
NEXT LEVEL
go to x: 0 y: 0
W i n
go to front laye r
show
touching Player B l o c k ?
wait until
hide
w h e n t h e p l a yse rs p’ r i t e
touches them.
w h e n I r e c e i v e Wi n
s w i t c h c o s t u m e t o Win
Lose
go to front laye r
show
go to front laye r
show
T O O P E N P AO RLOTT
NEXT LEVEL
uoY c a n g i v e e a c h l e v e l i t s o w n m u s i c . S e l e c t t h e G a m e
66 76
s o u n d l i b r a r “y, X y: l o 2 ” “, X y l o 3 ” a“. nX dy l o 4 ” Th e co d e
b e l o w w i l l s w a p t h e m u s i c e a c h t i m e y o u c h a n g e l e vel.
“ X y luo n2 t” i l t h e p l a y e r
r e a c h e s L e ve l 2 .
when c l i c ke d
Level = 2
repeat until
68
Level = 3
repeat until
Level = 4
repeat until
V i c to r y d a n c e
I f y o u t h i n k t h e e n d o f t h e g a m e i s ’nt e x c i t i n g
t o d o s o m e t h i n g m o r e s p e c t a c u l .a rM a y b e t h e
d o g c o u l d d o a l i t t l e v i c t o r y d a n c e ?Wh y n o t
add a new sign for when the dog falls off the
p l a t f o r m s a n d e n d s u p a t t h e b o t to m o f t h e
stage?
o uY c o u l d m a k e t h e d o g d i s a p p e a r t o o .
uoY w o n !
Ls e cte ’l e b r a t e !
◁
when c l i c ke d
“ a kTe o f f S p e ev da ”r i a b lueoY. c a n a l s o m a k e t h e v a l u e
set a keT o f f S p e e d to 12
of ”Grav i t sym”a l l e r o r l a r g e r t o c o n t ro l h o w f l o a t y e a c h
j u m p i s Why
. n o t a d d a s p e c i a l l e v e l w i t h r e ve r s e g r a v i t, y
set RunSpeed to 5
m a k e c o d e c h a n g e s t o s e t t h e j u m p v a r i a b l e s j u s t for
set Gravi t y to –1
t h a t l e v e l w i t h “i af nthen”
block, and also to detec t
w h e n t h e d“of ga lol fs f” t h e t o p o f t h e l e v e l !
Decreasing this number
m a k e s t h e j u m p s l e s s f l o a t. y
G A M E D E S I G N
Designing levels
iTr c k s r T y f o o l i n g t h e p l a ye r i n t o f o l l o w i n g w h a t
D e s i g n i n g h o w a l l t h e c h a l l e n g e s a n d r e wa r d s i n
t u r n s o u t t o b e a t r a pT. h e c o r r e c t w a y w i l l b e a n e a s i ,e r
e v e r y d e t a i l a n d g e t a f r i e n d t o t e s t i t t o s e e i f si t ’
t o o e a s y o r t o o h a r d. M a k e s u r e y o u c a n c o m p l e t e
t h e l e v e l y o u r s e l f b e fo r e a s k i n g t h e m t o t r y i t .
can’t g e t p a s t t h e m , o r s o s l o w t hs e’ re n o c h a l l e n g e ?
A d j u s t t h e i r s p e e d s u n t i l y or ’u e h a p p y w i t h t h e m .
ooT l s C o m p u t e r g a m e s o f t e n co m e w i t h l e v e l d e s i g n
Spacing Is the player able to jump from platfo rm to tools that are unlocked once you finish the game.
platform easily – or perhaps too easily? Make the gaps Using these you can cre ate your own challenges and
l evel you’
re d e s i g n i n g . c u s t o m i z e d l e v e l s o n l i n e, s o t h a t o t h e r s c a n t r y t h e m .
G l a c i e r
person with the most gems when
A I M O F T H E G A M E
I st r’ e d c a r v e r s u s b l u e c a r i n a ra c e - o f f a g a i n s t
t h e c l o c k . Wi n b y c o l l e c t i n g m o r e g e m s t h a n
y o u r o p p o n e n t b e f o re t h e c o u n t d o w n e nds.
snow or you’ l l e n d u p i n a s p i n .
Cars
U s e t h e g a m e c o n t r o l s to k e e p
gems.
o uY c a n a l s o p u s h t h e
an advantage.
Obstacles
Avoid th e g i a n t s n o w b a l l s
or you’ l l s p i n o u t o f c o n t r o l.
Penguin
of ceremonies. He asks
t h e p l a y enras m
’ es at the
s t a r t , g i v e s i n s t r u c t i o n s,
i s c o n t r o l l e d u s i n g t h eW, A , S ,
w i t h t h e a r r o w k e y s.
1
symbol t o c r e a t e a b l a n k s p r i t e a n d r e n a m e“G i at m. e L o o ”p
T h e n m a k e a v a r i a b l e c a l l“Countdown”
ed fo r t h e g a m e t i m e r
a n d s h o w i t o n t h e s t a g e . B u i l d t h e fo l l o w i n g c o d e to m a k e
“Calculate”
, , “Move” a“nGda m e O. v e r ”
“ C o u n t d o w”n in the
when clicked
Vari a b l e s s e c t i o n .
Countdown < 1
repeat until
broadcast GameOver
U s e “t hb er o a d c a bs lto” c k
broadcast message1
f o r y o u r c o d e.
New message
Name the
message1
message here.
W h e n t h e p r o j e c t r u n s , t h e c o d e s e n d s o u “t S aetup”
message
t h a t t e l l s a l l t h e s p r i t e s t o g e t r e a d y f o r t h e g a m e . I t w a i t s for
messages telling every sprite in the game when to run each part
o f t h e i r c o d eT. h e l o o p e n d s o n l y w h e n t h e c o u n t d o w n re a c h e s 0 ,
a t w h i c h p o i n t t“Gh ea m e O v e rm e” s s a g e i s s e n t s o a l l s p r i t e s c a n
p e r f o r m a n y f i n a l a c t i o n s a n d t h e w i n n e r i s a n n o u n c e d.
sprites each with its own loops
h a s t o c o n s t a n t l y j u m p b e t w e en
C r e a t e t w o n e w v a r i a b l e“ Rs :o a d( Yt o” s t o r e t h e y
coordinate used to p o s i t i o n o u r m o v i n g s c e n e r y)
a“Ca
n dr S p e e( dt o” s e t h o w q u i c k l y t h e c a r s c a n
set RoadY
the aV r i a b l e s s e c t i o n s o t h e y a r e ’nt d i s p l a y e d o n t h e
s t a g e . A d d t h e co d e o n t h e r i g h t t o s e t t h e v a l u e s o f
set CarSpeed
set C o u n t d ow n
reset timer
f o r t h e g a m e i n s e c o n d s.
s p r i t e s c a l l “eRdo a d S p e e d ”
w h e n I r e c e i ve C a l c u l at e
m o v i n g s c e n e r. y U n c h e c k
set RoadSpeed to –5
t h e t i c k b o xT. h e n c r e a t e
change RoadY by
RoadY
if
uoY’ l l s e e h ow t h i s w o r k s
once you’v e m a d e t h e
road sprites.
m o v e d o w n t h e s t a g e.
4
Costume costume1
. In“Road1”
call
theit
paint editor
, choose the
10
Fill
any gaps.
Then use the
snowy setting.
Leave the
r o a d e m p t. y
Convert t o Vecto r
5
Sprite R oad2
on“Flip
thevertical”
button at the top right
S h ow
Road1
R o a d 2 t o m a k e t h e s e c o n d r o a d s p r i te w o r k paint the backdrop rather
7 8
together with the first. Run the project – the than the sprites, or else the
road should scroll smoothly down the screen. cars will collide with the road
c l i c k o n t h e B a c k d r o p s t a b.
w i t h a n i c y b l u e c o l o .u r
s c e n e r y stays behind
go to x: 0 y: 360
the other sprites.
go backward 10 layers
RoadY + 360
go to x: 0 y:
else
RoadY – 360
go to x: 0 y:
t r e e s . S e l e c t R o a d 1 a n d c l i c k o n t h e C o s t u m e s t a b.
Create your ow n t r e e s o r b u s h e s u s i n g t h e t o o l s i n
t h e p a i n t e d i t .o rR e p e a t t h e p r o c e s s fo r R o a d 2 .
d r a w t h e c a r f a c i n g r i g h t o r i t w i l l p o i n t t h e w ro n g w a y
you’ve f i n i s h e d .
cat. Th e n e x t b i t o f
tool to draw an
oval s hape.
1 1 2 1
list. Th e n c r e a t e a n e w v a r i a bs“l ep,,i n n i n g ” code only when they get messages from the
which you’ l l u s e l a t e r t o s a y w h e n a c a r G a m e L o o p . A d d t h e f o l l ow i n g c o d e t o s e t
is in a spin. Note that for this variable, you up the red car at the start of the game.
n e e d t o s e l e c t t h e o p t i“of no r t h i s s p r i t e
o n l ayn ”d u n c h e c k t h e t i c k b o x i n t h e
Vari a b l e s s e c t i o n s o t h a t t h e v a r i a b l e
doesn’t s h o w o n t h e s t a g e .
when I receive Setup
set size to 30 %
New
Va r i a b l e
show
Make sure
go to front
you select
spinning
this option.
go to x: –40 y: 0
For a l l s p r i t e s oF r t h i s s p r i t e o n l y
point in direction 0
Cancel OK
set spinning
key d pressed?
if
This block
moves the
point in direction 30
car sideways.
change x by CarSpeed
key a pressed?
if
change x by CarSpeed
0 –
key w pressed?
if
change y by CarSpeed
This block
up the stage.
key s pressed?
if
change y by RoadSpeed
A d d s o m e c o d e t o r u nc t“h e a r c o n t r o l s ”
41
“Move”
f r o m t h e G a m e L o o p. R u n t h e
p r o j e cuotY. s h o u l d n o w b e a b l e t o s t e e r
car controls
t h e r e d c a r a l o n g t h e r o a d u s i n g t h e k e ys
, WA , S , a n d .D
a n d t h e n c l i“ cMk a k e a B. lNoacmk e” t h e b l o c k
hc“ e c k c o l l i s i o na ns ”d c r e a t e t h e f o l l o w i n g c o d e .
set spinning to 30
h o w l o n g t o s p i n f. o r
61
, a n “spin
d a” d d t h e c o d e s h o w n
define spin
here. sTh
“ bpin”
el o c k r u n s w h e n
“spin ning”
v a r i a b l e b y o n e W. h e n
turn 30 degrees
t h e v a r i a b l e r e a c h e s z e ro, the
change spinning by –1
change y by RoadSpeed
if spinning
go to x: –40 y: –180
point in direction 0
i f t h e s p i n i s o v. e r
“spin n i ns g m” o r e t h a n
zero, t h e c a r w i l l s p i n .
oT a d d s o m e s n o w b a l l o b s t a c l e s , c r e a t e a n e w s p r i t e
81
i n t h e p a i n t e d i t .o rM a k e i t a b o u t t h e s i z e o f t h e c a r
o n t h e s t a g eoT. g e t t h e c o r r e c t s i z e, w a t c h i t a p p e a r
t h e c o s t u ms es ’i z e i n t h e c o s t u m e l i s t – a i m f o r a b o u t
4 0 x 4 0 . N a m e t h e n e w s p r “i tS en o. w b a l l ”
Costumes
Sounds
Code
Costume Snowball
10
Fill
Snowball
40 x 40
These
numbers
show the
c o s t usm e ’
size.
Use the
“ S etool
lect”
to resize
the sprite.
Convert t o Vecto r
This block hides
go to x: p i c k r a n d o m– 2 0 0 to 200
show
RoadSpeed
change y by
Now select the Game Loop spr ite and add this
02
b i g g e r c r e a t e s f e wer
snowballs.
create clone of S n ow b a l l
set spinning to 30
Playertwo
uoY n o w n e e d t o c r e a te t h e s e c o n d p l a y e rs car’ .
car, r e c o l o u r i t b l u e , a n d t w e a k t h e c o d e b l o c k s .
D u p l i c a t e t h e R e d C a r s p r i t e a n d n a m e t h e copy
2
Sprite
“ B l u. eNCoat re ” t h a t t h e d u p l i c a t e s p r i te g e t s i t s
o w n c o p y o f a l l t h e c o d e b l o c k sT. h i s i n c l u d e s a
S h ow
c o p y o f st“ hpe i n n i nv ga ”r i a b l e ( s e t “ tf o r t h i s s p r i t e
o n l y ” ) , w h i c h c a n b e d i f f e r e n t f r o m t h e r e d c s.a r ’
32
p a i n t e d i t .o rU s e t h e f i l l t o o l t o
c h a n g e t h e c sa rc’ o l o .u r
point in direction 0
I n t “hDee f i n e c a r c o n t r o l s”
key r i g h t a r row
if
52
c o d e , c h a n g e t“ hkee y
p r e s s ebdl o” c k s s o t h a t
point in direction 30
s t e e r e d u s i n g t h e a r r ow
change x by CarSpeed
key l e f t a r ro w pressed?
if
0 – CarSpeed
change x by
key u p a r r ow pressed?
if
change y by CarSpeed
▷
key d o w n a r ro w
Change the code
if
I n t “hkee y p r e s s e db ?l o” c k s ,
r e p l a c ed k”“ e y w“irtihg ht
change y by RoadSpeed
a, r a”kr“ eo yw ”w i“ tl he f t a r, r o w ”
“s”key dwow
i“ t hn a. r r o w ”
touching Road1 ? or touching Road2 ?
if
set spinning to 30
broadcast bounce
f r o m B l u e C. a r
N o w m a k e t h e s a m e c h a n g e s t o B l u e C sa rc’ o d e b l o c k s s o
72
i t c a n s e n s e w h e n i t t o u c h e s R e d C a r a n d b o u n c e. R u n t h e
broadcast bounce
T h i s t i m e “t ht oe u c h i n g ”
w i t h t h e r e d c. a r
create a new sprite with
t h e p a i n t e d i otT.o cr r e a t e
Fill
w i t h a d i f f e r e nt s h a d e o f
Name the
. s p r“ iGt e m
”
Gem
40 x 33
C r e a t e t w o v a r i a b l e s“ R–e d C a r G e ma nd
s”
92
set RedCarGems
s p r i t e ; t h e yre’ s i m i l a r t o t h e c o d e b l o c k s
set BlueCarGems
f o r t h e s n o w b a l l s.
go to front layer
hide
show
start sound Fairydust
change RedCarGems by 1
change C o u n t d ow n by 1
touching BlueCar ?
if then
change BlueCarGems by 1
change C o u n t d ow n by 1
if
y position
< –175
g e m s 1 0 t i m e s m o r e c o m m o n t h a n s n o w b a l l s.
uoY’ l l n o t i ce t h a t t h e
23
c o u n t d o w n i s n ’t w o r k i n g
oT f i x t h e p r o b l e m , a d d t h e
if timer >
change C o u n t d ow n by
t h e g a m e a g a i n . Wh e n t h e
c o u n t d o w n r e a c h e s zero,
reset timer
if Countdown
Ti“hf i tshbelno”c k p l a y s
s“pop”
ounds in the last
t o w a r n t h e p l a y e rs
First , c r e a t e f o u r v a r i a b l e s f o r a l l
Penguin in charge
33
s p r i t “eRs e: d N a m e ” a“ nB dl u e N a m e ”
“ R e d I n f ”o a“nBdl u e I n f ”o to show
a g a m e l o o k m o r e p r o fe s s i o n a l .
e a c h d r i v se rs ’c o r e d u r i n g t h e r a ce.
the players’
n a m e s , s t a r t the race,
t o t h e p l a y e r s, a n d l o a d t“Gh eong”
hide
t h e p l a y se cr so’ r e s
on the stage.
show variable BlueInfo
reset timer
E X P E R T T I P S
A s p r i t e c a n p u t a q u e s t i o n t o t h e p e r s o n a t t h e c o m p u te r b y u s i n g ta“h es k ”
£ 1 0 0 ? ? T hs a t ’
How much is
daylight ro b b e r y !
when
t h e c a c tus juice?
next costume
think
£100
R u n t h e g a m e . H i d e a l l v a r i a b l e s e xc e“Countdown”
pt,
63
in the aV r i a b l e s s e c t i o n . Th e n r i g h t - c l i c k t h e R e d I n f o a n d
B l u e I n f o s i g n s o n t h e s t a g e a n d c h o o“ sl ea r g e r e a. d o u t ”
oT m a k e e v e r y t h i n g l o o k t i d y , d r a g t h e s i g n s t o t h e t o p
l e f t a n d m o v e t h e c o u nt d o w n t o t h e t o p r i g h t .
Ben Gems: 20
Countdown
Laura Gems: 13
start sound Gong
Type a s p a c e b e f o r e
go to x: 0 y: 0
t h e wo“ wr di n s ! ”
go to front laye r
RedName wins!
say join
else
BlueName wins!
say join
else
S i n c e t h e o n l y p o s s i b i l i t y l e f t i s a d r a, w
you don’t n e e d t o a de d “ a n q u ab l ls o” c k .
F i n a l ,l y a d d s o m e r h y t h m i c d a n c e
83
m u s i c t o m a k e t h e g a m e f e e l f a s t .e r
when clicked
L o“ aDda n c e A r o u ntod ”t h e G a m e
L o o p s p r i t e a n d t h e n a d d t h i s code.
forever
I s t a’ l o o p , a n d e x t r a l o o p s c a n s l o w
r u n s o n c e e v e r y f e w s e c o n d s i t w o n’t
a f f e c t t h e g a m e p l a. y
S o u n d s t a b . Th e n c l i c k t h e m i c r o p h o n e i c o n i n t h e s o u n d s
m e n u t o m a k e a r e c o rd i n g . R e p l a ce t h e P es“nguin’
as y ”
a recording.
Record
Fine-tuning
oT c h a n g e h o w h a r d o r e a s y t h e g a m e
i s , a d j u s t t“ hC ea r ,S p e e d ” “ R o a d S, p e e d ”
a“Countdown”
nd variables that are set
a t t h e s t aor utY. c a n a l s o a d j u s t h o w l o n g
t h e c a r s s p i n f o r a f t e r a c ra s h , h o w b i g t h e
b o u n c e i s w h e n t h e y c o l l i d e , a n d h ow
o f t e n s n o w b a l l s a n d g e m s a p p reT.a r y t o
Laura Gems: 13
move
One-player game
I s t e’ a s y t o c h a n g e t h e s e t t i n g o f G l a c i e r R a c e b y w h e r e y o u p l a y a g a i n s t a c o m p u t e r - c o n t r o l l e d b l u e c .a r
r e p a i n t i n g t h e s c e noeuYr. yc a n m a k e t h e p l a y e r s F i r s t s a v e a c o p y o f t h e p r o j e c t s o y o u d o ’nt s p o i l t h e
R o a d S p e ebdl o” c k i n t h e G a m e L o o p s p r i t e s o t h a t t h e
G A M E D E S I G N
Camera angles
ct h“ e amera”
in a computer game.
This refers t o h o w t h e p i c t u r e o n t h e
s c r e e n f o l l o ws t h e a c t i o n i n t h e g a m e .
a c t i o n , y o u c a n t h i n k a b o u t d i f f e rent
w a y s o f s h o w i n g w h as t g’ o i n g o n .
H e r e a r e s o m e c o m m o n c a m e ra
△ △
around the game. In Glacier player would see through their own
R a c e , t h e c a m e r a fo l l o w s t h e eyes. Fi r s t - p e r s o n g a m e s m a k e t h e
T
Score
A I M O F T H E G A M E
Inrop
T icaluTn e s , y o u h a ve t o l i s t e n
t h e e v e r - g r ow i n g t u n e . M a k e a m i s t a k e
a n d t h e g a ms eover
’ . Th e l o n g e r y o u
c a n m a t c h t h e t u n e f o, rt h e h i g h e r
your score.
◁ Listen
◁ Drums
g a m e p l a y s t o y o u.
◁ Game over
t u n e g e t s l o n g ,e rt h e
g a m e g e t s h a r d .e r
C r e a t e a n e w S c r at c h p r o j e c t a n d
to open the
b a c k d r o p l i b r a r. y
Choose a Backdrop
T h e g a m e n e e d s f o u r d r u m s, b u t y o u
t h e c a t s p r i t e a n d a d d t“hDrum”
es p r i t e
f r o m t h e s p r i t e s l i b r a r. y D r a g i t t o t h e
Th e n a“mD er u m
”
l o w e r l e f t o f t h e s t a g e.
s p r i t e a u t o m a t i c a l l. y
Uncheck their tick boxes. Every sprite
NewVa r i a b l e
4
Call drumColour”
“them
, d, “ rumNote” and
r d “ umNumber”
hT. ese variables will only
New variable name:
drumColour
number
, its colour
, and which note it plays.
“For
Using
this sprite enables
only” you to
For a l l s p r i t e s
First a d d t h e M u s i c e x t e n s i o n , t h e n b u i l d t h e c o d e
b e l o w f o r t h e D r u m s p r i te . I t s e t s u p t h e d r usm’ n u m b ,e r
c o l o ,u rt h e n o t e i t p l a y s , a n d t h e t y p e o f s o u n d i t m a k e s
a n d w a t c h t h e d r u m c h a n g e c o l o .u r
T h i s d rsu m ’
variable
information
when clicked
is set up in
these three
set drumNumber to 1
blocks.
set drumNote to 60
set instrument to ( 1 8 ) S t e e l D ru m
Add an input
number or text
My Blocks
R u n w i t h o u t s c r e e n r e f re s h
Make a Block
7
Make a Block
, appearsdrum”
in the code area.
play drum
B u i l d t h i s c o d e b e l o wd t“h e e f i n e p l a y d r u m ”
8 9
b l o c k . Th e n i f y o u u s e tp“hlay
e drum”
block
a n y w h e r e, S c r a t c h w i l l r u n t h i s c o d eT. h e c o d e
w i l l m a k e t h e d r u m g r o w i n s i z e , p l a y a n o te,
a n d t h e n s h r i n k b a c k t o n o r m auolY. c a n t e s t
t h e n p“e lay
w drum”
block by clicking on it.
if
m e n u o n t“hwe h e n I
receive”
block. Choose
play drum
“ N e w m e s s a ga en ”d t y p e
“ Ri ne m o t e C o. n t r o l ”
How it works
1 t o 4 ( t h e l o c a l v a r i a b l e d r u m N u m b e r ) . B e f o re
t h e m a s t e r c o n t r o l l e r b ro a d c a s“ Rt se m o t e C o n t r o l ”
a n d o n l y t h e m a t c h i n g d r u m w i l l p l [Link]
w i l l a d d t h e s e s t e p s l a t .e r
MESSAGE
b e c a u sder u“i mt sN u m b e r ”
m a t c “h De rsP. ouT ml a y ”
Drum Drum3
Drum2
Fourdrums
uoY n o w h a v e o n e d r u m co m p l e t e w i t h i t s c o d e b l o c k soY. u c a n c o p y
i t t h r e e t i m e s t o c r e a t e t h e f o u r d r u m s yo u n e e d f o r t h i s g a m e.
D u p l i c a t e t h e d r u m t h r e e t i m e s, t h e n c h a n g e t h e v a l u e s o f t h e
2 1
t h r e e l o c a l v a r i a b l e s a s s h o w n b e l ow t o g i v e e a c h d r u m a d i f f e r e n t
n u m b ,e rc o l o ,u ra n d n o t e . A r r a n g e t h e d r u m s o n t h e s t a g e , o r d e re d
f r o m o n e t o f o .ur
when c l i c ke d
set drumNumber to 1 to 2 to 3
set drumNote to 60
to 62 to 64
31
b e c o m e a d i f f e r e n t c o l o .u rS e l e c t t h e m i n
t u r n t o h e a r t h e m p l a. y I f t h e y m o v e i n s t e a d
w o r k y e t , b u t s i tg’ o o d t o t e s t t h a t y o ur
d r u m s a l l p l a y c o r r e ctly.
The stage is a good
41 Stage
a s t h e y d o n ’t b e l o n g
otanoynGo
.esptirto
Backdrops
Click here to
to the stage.
5 1
o f t h e e v e r - g ro w i n g s e q u e n c e o f
n u m b e r e d l i s toT. c r e a t e t h e l i s t ,
o p e n t h e aV r i a b l e s s e c t i o n a n d
DrumOrder
c h o o s e t“hMe a k e a L i sb tu ”t t o n .
N a m e“ Di tr u m O r d e– r ”si tg’ o i n g t o
For a l l s p r i t e s oF r t h i s s p r i t e o n l y
will play. C h e c k t h e t i c k b o x s o y o u
Make a List
Tick here to
DrumOrder
on stage.
Run the code and watch the
DrumOrder
7 1
“ D r u m O r d el irs”t o n t h e s t a g e
1 4
t h i s , b u t y o u r n u m b e r s won’t
2 3
b e t h e s a m eT. h e d r u m s d o n ’t
3 1
b l o c k s t o t e l l t h e m t o.
4 3
5 1
6 2
7 2
+ length 7 =
E X P E R T T I P S
Lists
M a k i n g a l i s t i s a g r e a t w a y to store
Lists are usually
l a n g u a g e s u s e t h e m . Th e y a r e h a n d y
f o r a l l s o r t s o f t h i n g s , f r o m c re a t i n g
like variables.
i n t e l l i g e n c e . I nTrop icaluTn e s , w e u s e
store word s i n l i s t s t o o .
something random
“DrumT
o Pl a f yr o” m t h e l i s t ,
“ R e m o t e C o n t r mo le” s s a g e .
A d d t h e np“e lwa y s e q u e n c e ”
91
block to the test code.
when c l i c ke d
repeat 7
wait 1 seconds
P l a c e t h e np“ elay
w
s e q u e nbcleo” c k h e r e .
play sequence
E X P E R T T I P S
Broadcast blocks
T h e r e a r e t wo t y p e s o f b r o a d c a s t S c ra t c h b l o c k s The
. y a r e u s e f u l i n d i f f e rent ways.
broadcast Message
broadcast Message
△ △
r e c e i v i n g c o d e b l o c k s h av e f i n i s h e d b e f o r e r u n n i n g
t o t h e n e x t b l o c k w i t h o u t w a i t i n g T. h i s i s u s e f u l f o r
t h e n e x t b l o c k T. h i s i s u s e f u l w h e n y o u d o ’nt w ant
t r i g g e r i n g a n e v e n t w i t h o u t s t o p p i n g w h sa tg’ o i n g
t h e c o d e t o c o n t i n u e u n t i l s o m e t h i sn gf ’i n i s h e d ,
on, such as launching an arrow without pausing
when clicked
S o f a r y o u ’v e j u s t b e e n t e s t i n g t h e
d r u m s . I st n’ o w t i m e t o g e t t h e m
set Score to 0
forever
t h e p l a y e r r e p e a t s t h e t u n e c o r r e c t l.y
wait 2 seconds
T h e t e s t c o d e i s ’nt n e e d e d a n y m o r e
12
s o r e p l a c e i t w i t h t h i s oonu’[Link] l n e e d
play sequence
“ w a i t f o r p l a ye –r i”t s c o d e i s s h o w n
w a i t f o r p l a ye r
i n t h e n e x t s t e poY. u’ l l a l s o n e e d t o
c r e a t e a n e w v a r i a b l e f o r a l l s p r i t e s,
c a l, l“eaScore”
dn d c h e c k i t s o i t
A d d a n e w v a r i a b l e c a l l“Co
e dr r e c t Co u ntot ”c o u n t h o w
m a n y d r u m s t h e p l a ye r g e t s r i g h t T. h e n c r e a t e t h i s c o d e,
w h i c h h o l d s u p t h e l o o p w h i l e i t w a i t s f o r t h e p l a ye r t o
define w a i t f o r p l a ye r
set Count to 0
set C o r r e c t Count to 0
m e s s a g e . I f t h e n u m b e r s d o ’nt m a t c h , t h e g a m e e n d s .
This is the
number of
change Count by 1
the correct
drum held
in the list.
change C o r r e c t Count by 1
Create a new
change Score by 1
message
called
else
“ G a m e. O v e r ”
broadcast GameOver
52 62
n e e d t o l o a d t“hBell
eo sl oTl ”u n d t o t h e s t a g e r e m e m b e r t o u n c h e“ cDkr u m O r d ei nr ”the aV r i a b l e s
Uncheck the
box to hide
f r o m t h e p l a y. e r
stop all
“ C l i c k me de ”s s a g e t e l l s
Drum Drum2
skcaH t kdna ae w s
Once everything is
Obey me!
w o r k i n g s m o o t h l, y
t w e a k t h e g a m e t o t r y and
m a k e i t m o r e e xc i t i n g o r
h a r d .e rH e r e a r e s o m e i d e a s .
△
laT k i n g s h a r k
Try a d d i n g a s h a r k s p r i t e
t a l k u s i n g st“h ae by l ”o c k .
14
Round counter
“ R o u nadn ”d s h o w i t o n t h e
s t a g e . S e t i t t o ze r o a t t h e s t a r t GAME
completes a sequence
OVER!
correctly (at the end of the
“ai nf d ” blocks
change Count by 1
other when
be? Or are
change C o r r e c t Count by 1
another when
change Score by 1
they should
be inside? else
broadcast GameOver
go to Launcher
Have you
confused similar
b l o c k sg ol “i k e Is a loop that
x
Sprite Drum 20
If a sprite
disappears from
is tn ’o t h i d d e n –
Drum Drum2
“showi c o ”n .
Try s h o w i n g k e y v a r i a b l e s o n t h e
ClickedDrum
s t a g e b y c h e c k i n g t h e i r t i c k b o xe s i n t h e
orange aV r i a b l e s s e c t i o n . I f t h e i r v a l u e s
DrumT
o P lay
l o o k o d d o r d o n ’t c h a n g e , t h e y m i g h t
g i v e y o u a c l u e a b o u t w h sa tw’r o n g .
to the Scratch website at www. s c r a t c h . m i t . e d u
s e e s h a r e d p r o j e c t s.
S C TCH
RA
Explore
Projects St u d i o s
byWork i n g W i t c h 1 1 1
D e f e n d t h e w i t c h a g a i n s t c re a t u r e s o f t h e
c a s t i n g f i r e b a l l s ( s p e l l b u t t o n ) . Fl y i n g h i p p o s
g i v e e x t r a l i v e s b u t m a k e s u r e you don’t h i t
c h a r a c t e r s , o b j e c t s , l e v e ls,
and actions.
3 4
c h a r a c t e r s o i t w o r k s w i t h yo u r c h o s e n c o n t r o ls e l s e t o p l a y i tT. h e y m i g h t f i n d p r o b l e m s t h a t y o u
( k e y b o a r d , m o u s e, o r o n - s c r e e n c o n t r o l l e r )T. h e n m i s s e d b e c a u s e y o u k n o w t h e g a m e t o o well. Fi x
cerantigthecodnteiedtosplaytisparnhtiegame.
Share it!
G o t o t“hS ee e P r o j e c t P abge”
utton at the top of
See Pro
t h e S c r a t c h e d i t o r a n d a d d a fe w w o r d s t o e x p l a i n
h o w t o p l a y t h e g a m [Link] e n s e l e“ cS thare”
to allow
t h e w h o l e w o r l d t o p l a y y o u r m a s t e r p i e c [Link] l l
set x to 240
forever
t h e g h o ss t ’
next costume
costume loop
set ScreenEdge
wait 1 seconds
set x to
△ △
▽ a code block or
Backpack
s p r i t e t o c o p y it
T h e b a c k p a c k i s a f e at u r e f o u n d a t t h e b o t t o m
to the backpack .
o f t h e S c r a t c h s c r e e n . I t l e t s y o u s t o re u s e f u l
c o d e b l o c k s , s p r i t e s, s o u n d s , a n d c o s t u m e s
Backpack
Tuto r i a l s
t u t o r i a l l i b r a r. y
A video
explains every
concept in
detail.
E X P E R T T I P S
Scratch projects often look and sound similar if you only use
r e s o u r c e s f ro m t h e S c r a t c h l i [Link] m a k e y o u r s d i f f e rent,
i m p o r t y o u r o w n i m a g e s a n d s o u n d s i n t o S c r a tc h .
▷ ▷
Camera
uoY c a n i m p o r t a n y i m a g e uoY c a n r e c o r d y o u r o w n
s h a r e a p r o j e c t co n t a i n i n g t h r o u g h y o u r c o m p u te s r ’
to use your
take a picture.
[Link] u c a n a l s o c r e a t e i n S c r a toc hY. u can also find
Play games
ones.r T y o u t d i f f e r e n t g a m e s a n d w a t c h o t h e r
p e o p l e p l a y i n g t h e m T. h i n k a b o u t t h e a c t i o n s
g a m e w o r k . I m a g i n e h o w y o u m i g h t co d e t h e s e
d i f f e r e n t p a r t s o f t h e g a m e y o u r s e l. f
▷ ▷
Explore
Find stories
gaming history
I d e a s f o r g a m e s a n d t h e c h a r a c t e rs
h i s t o r y o f g a m i n g Vis
. it a
Next time you watch a good film or
a v i n t a g e a r c a d eT. h e re
might turn it into a game.
g a m e s , s o s i te’ a s y t o t r y
c l a s s i c g a m e s t h i s w a. y
Think visually
d e s i g n .e rP r a c t i s e d ra w i n g o r t r y m a k i n g
m o d e l soT. h e l p c r e a t e a n i m a t i o n s, f i l m
you’ll b e a b l e t o c o d e t h i n g s
J a v a S c r i p t T. h e r e a r e l o t s o f o n l i n e co d i n g
c o u r s e s , i n c l u d i n g s o m e t h a t fo c u s o n
P y g a m e t h a t h e l p s y o u c re a t e g a m e s .
Try a g a m e e n g i n e
uoY don’t h a v e t o b u i l d c o m p u t e r
g a m e s f r o m s c r a t c h – yo u c a n u s e
you.
o uY c a n f i n d g a m e e n g i n e s
o n l i n e . M a n y c a n b e t r i e d f o r f r e e.
E X P E R T T I P S
Game engines
p r o f e s s i o n a l g a m e d e ve l o p e r s G a m e e n g i n e s c a n a l s o c o n ve r t
p r o j e c t , t h e r e m i g ht b e d o z e n s o f p r o gr a m m e r s a n d
△ △
L I N G O
Game types
,g ta hmeesse” a r e c r e a t e d b y p e o p l e
in mainstream games.
Composer
and are expected to sell millions of copies.
T h e y t a k e m a n y m o n t h s o r e ve n y e a r s t o
A composer is a professional
i t h e l p s c r e a t e a t m o s p h e re
in a game.
g a m e s a l l d a, y b u t si ta’ s e r i o u s a n d i m p o r t a n t
ideas and building blocks
w o r k s c o r r e c t l y a n d i s n o t t o o e a s y o r h a r d.
that makes the game work.
G A M E D E S I G N
Game development
d i f f e r e n t ve r s i o n s b e f o re t h e f i n a l
o n e i s r e l e a s e d f o r s a l e The
. early
“Notch”
Persson r e l e a s e d t h e f i r s t
v e r s i o n o f M i n e c r a f t, a b u i l d i n g g a m e
dhe’m a d e . B y 2 0 1 4 , M i n e c r a f t h a d
Prototype Alpha
1 2
experimental version of m a i n f e a t u r e s, b u t t h e y m i g h t
i s f u n t o p l a. y fixed befo r e t h e n e x t s t a g e .
Beta Release
3 4
a n d I n d e x
n a m e d a f t e r t h e i n s e c t s that program can re act to, such
a r t i f i c i a l i n t e lligence (A I )
P r o g r a m m i n g to m a k e
camera execute
run
T h e i m a g i n a r y camera See .
i n i n t e l l i g e n t w a y s.
views a game.
export
assets
code
computer from Scratch, such
backdrop
a r e r u n i n o r d. e r
file
collision detection
A collection of data stored
stage in Scratch.
with a name.
Programming t h a t d e t e c t s
backpack
flag
game are touching.
A s t o r a g e a r e a i n S c ratch
t h a t a l l o w s y o u to c o p y
condition
to pass information
t h i n g s b e t w e e n p r o j e c t s.
c o d e b l o c k t o a n o t h. e r
block
An instruction in Scratch
function
Boolean expression
.
console
specific task, work ing like a
p r o g r a m w i t h i n a p r o gram.
Boolean expression
A l s o c a l l e d a p r o c e d u r e,
j u s t f o r p l a y i n g g a m e s.
A statement that is
subprogram, or subroutine.
costume
game engine
T h e p i c t u r e a s p r i t e shows
outcomes. Boolean
blocks in Scratch
c h a n g i n g a s p r si t ec o’ s t u m e s
by providing re ady-made
than rounded.
c o d e f o r m a n y co m m o n
g a m e f e a t u r e s, s u c h a s
data
a n i m a t i o n , c o n t r o l s,
I n f o r m a t i o n , s u c h a s t ex t ,
symbols, or numbers.
t h e c o m p u ts e fr i’ l e s . o r b e c o m e i n v i s i b l e. procedure
index number
subprogram, or subroutine.
input
message
program
c o m p u t. e Kr e y b o a r d s , m i c e,
between sprites.
c o m p u t e r f o l l o ws i n o r d e r
to complete a task.
network
A g r o u p o f i n t e r co n n e c t e d
programming language
integer
A w h o l e n u m b. e Ar n i n t e g e r
data. Th e i n t e r n e t i s a
to give instructions to
giant network.
a c o m p u t. e r
a fraction.
project
i n t e r f ace
Scratch’
s n a m e f o r a p r o gr a m
e v e r y t h i n g o n a c o m p u t, e r
s u c h a s Wi n d o w s , m a c O S ,
or Linux.
GUI
or hardware. S e e .
operator random
library
A collection of sprites,
b e u s e d i n S c r a t c h p r o gr a m s .
list
n u m b e r s t o g e t h. e r recursion
A c o l l e c t i o n o f i t e m s s t o re d
C r e a t i n g a l o o p b y te l l i n g
i n a n u m b e r e d o r d. e r output
a f u n c t i o n t o c a l l i t s e l. f
D a t a t h a t i s p r o d u c e d by
local variable
run
a p r o g r a m s t a r t.
Scratcher
of the variable.
3 1 1
animation
0 1 , , 1 47 41 ,5, “ b o u n c e ” m e ssage 118 c l o n e s 8 0 –3
65
201
a r i t h m e t i c o p e r a t 1o 2r s 1 “ b r o a d c a s t ” b l o c k s 6078, , 1 m a k i n g f r i e n ds a n d e n e m i e s
185 4 6 82
creating 34 b u m p e r s p r i t e41s 6 5 1 1
d e s t r o y ing 82
enemy
6 1 83, 1
e x p l o 8s 1i o 1n 9–1
a n d G a m e L o o p s p r 78ite 1
+C 28
m a k i n, g9718
b a c k d r o p l i b r a r y4 1 89, 41 “ C a l c u l a t e ” m e s s a 07g e 1
c l o s e d - i n space 63
b a c k d r o p5 s 1 calculations 20 0
189
adding
2 1 3 4, 1 clubs
camera angles
53
c o d3 i n1g 2
a d d i n g c o l o1 u5 r 1 cameras
c o d e b l o c k s 22
choice 2o3f 1 “car c o n t r o l s ” b l o 7c k 1 85, 10
a c t i vating 23
continually changing colou r c a r d g a m e 6s 1
building 32–3
2 1 1 c e n t r e p o i n t s , s p rites 65,
, 7871
copyi ng 83
creating you r own
23 1 m o v i n4g 1 6
and event s 95
D o gs ’Di n n e4r 18 “chan g e c o l o r ” b ,l o c k 74 89
and mess a g e s 6 8 , 69
D o o m o n t h e 2B r o1 o m 1 “chang e score by ” b l o c k 8 3
p a u s i n55g 1
G l a c i e r Race
73 1 “chan ge size by ” bl ock 89
triggering 95
Jumpy Mon key103 c h a r a c t e 2r s 1
c o d e a r e a 26,27
p l a t f o r1 ms5 1 D o gs ’Di n n 2e3r 1
bugs 46
Tr o p i c aul nT9es
93,1 1 4 G l a c i e r Race16 8
c 3lubs
1 2
x y - g r i d4 1 8 Jumpy Mon key92
164
i m p r o v i n g y o u r s k i l l13s 2
b a c k p a c k (Scratch),25,26,27 Star Hu nter 30
c o l l e c ti n g
0 209,
12 “che ck collisi o n s ” b l o c k 76, 1 181
5 0 – 73
b o n e s651 7 –
b a l a n c e d space61 CheeseChas e
eg ms82–1 4
“ B e s t t im e ” 8 8 adding e n e m i e s 5 8 , 6 67 –
s t a r s 4 10 –
b e t a v e r s i5o n 1s 2 a d d i n g i n s t r u c t i o n s 73
E
205
59
“def i n e ” b l o c536
718k, ,101 e n e m i e2,s 1 22 music
5 1 1 4 2, 1 3 1 1 2 , 1 0–2 5 playabili t y
63
dice 39 clones 83 v i r tu a l r e a l i t y
d i f f i c u l t y level
3 1 s u p e r n a t u r 2a l 1 4 –5 working with the m e s
a d j u s, t72–3,
i n g7488 , 928, , 1 7 “eq ual to” blo c k 6 6 g a m e d e s i g n e r1s 42
ex t r a lives
28 1– 9 e r a s e r t o ol 62, 65 g a m e d e v e l o p m e nt
38
95
132– 65
22
b o n e s f o r t h e d o56
g 17 – 203,
204
s p r i 2t e5 1 –3 g a m e p u b l i s h 5e r12s
see also
placing t h e p o r t als
5 41 –5 f i r s t - p e r s o n g ames189 f i n e - t u n i n g 4 66, 1 08,1 1– 8
player on a plat f o r m
3 41 –5 f i x e d c a m e r a a n g el189 game ty pes
r u n n i n g a r o u n36d 17 – f l a g5 s5 1 G l a c i e r Race
011 2– 9
f i r e - b r e a t h i n g d r a g o2 n 1 2–3 ex t r a lives
28 1– 9 r o Tp i c au lnTes
g h o s 4t s2 1 –5 f u n c t i o n3s 1 6 t y p e s o6f 71 1 –
i m a g e s , i m p o r t i n g your own designing n ew16 0 Minecraft 5 12
Indie gam
4 e1s 2 f i n e - t u n ing16 0 m o d e l 2l i n g1 2
8162–3, 8 , 2 0 4 l i n e w i d t h co n t r o l 6 0 391
200
w r i t i n g s e q u e n c e s9o8f11 – 0lives
1 1 “move”b l o c k s 39
l o c a l v a r i a b l e95s 1 d e t e c t i on 95
J a v a S c r i 3p t 821, l o c a t i o n s , a n d a t m o s p h e 5r e 1 d i r e c tions
35 371
59
171
b u g4s 10 – 24 game
07 , 1 i m p o r t i n g your
1 own1 2
07192– 80
r e p e at , 96 music games
7 1
Jumpy Monkey
see also
a d d i n g s o u n d0 1 3 “ L o o p s ” 95
b a n a n a s a n d t r e e97s– 9 l o s i n g 8 4 –5
h a c k s a n d t we a k s 106 7 – n a m e s , c h o i c 0eof21
“Make a Bl o c k ” b u t t 5o36
7 n, ,11 “ n o t ” block 9 9
691 n o t e s , k e e p i n g2 2120,9
199
arrow key31,652,
, 59,1s 1 m a t h e m a t i c a l c o l l i s i o n d e te c t i o n
180 146
see also
l e t ter keys
57 69, 11 m a z e m a k i n g 6 0 – 63 o b j e c t2s 1
s h i f t key
16 m e c h a n i c2 s 1 choice o f 22,
23 1
, space
1 1b 3ar1 13 m e m o r, tey s t i n g y o u91r 932, 1 clones 82
S
see also
s l i d e r s 104 –5,70 1
Scratch s a n d b o x g a m e 6s 1
164
of43 1
p r o j e c t page 73,81 8 , 2 0 9 “say ”81, bl 8o,7c2 k2 014
project s s o u n d d e s i g n e r1s 42
s c a r y f e a t u r e4,s 591
112
m a k i n g t h e m d i f f erent sounds
D o o m on the2 Br10o1o m, 1 1
a d d i 2n g 135,83,03,161, 3,1
sharing 208 0 2 1 142 –, 1–5
p r o t o t y 5p e 1s 2 6 7 1
scenery 21 3
p u z z l e2 s 1 7 , 1 at end of g ame163
c h a n g i n g8 18
P y g a3 m1e 2 a t m o 2s p h1e21er43, 1
making mo re interesting 73 1
C h e e s e Chase 59,72
“score ” b l o c k 4 4
Circle Wa rs 83
score cou nter 42,57
D o gs ’Di
, n7n e4r 161 3
“ S c o r e ” v a r 4i a1b l 202
e, 1
D o o m on the Br
2 8o1o m ,, 1
s c o r 3e s 1
421
q u e s t i o n s , s p r i t e s85’ 1 C h e e s e Chase70
and event s 95
Circle Wa rs79, 8 4 –5
G l a c i e r Race
6 7 18, 1 148,7
G l a c i e r Race18318, 148, 6
i m p o r t i n g your
1 own1 2
h i g h s c o r e 07
music 59
r a c i n g g a m e s6 1 a n d s o u n d s 83
see also
a n d s c o r es 83
random block 204 r o Tp i c au lnTe9s 91
22–7
s o u n d l i b r a ,r 8 1y424172,
7, , 11
6 17 1 1 , 1 expandingknowledge of
,s p a1c e 1b 3a r 1
7 1 1 exploring 20 8
39
d i s a b l i n 4g 1 0
random numbers , 40 i n t r o d u c i n g 2 2 –3
space in game s
random sequences 200 l e a r n i n g m o r e a b3o u 1t 2
speech bubbles
random speech 200 name of 24
and arit h m e t i c o p e r a t 1o 2r s 1
r a n d o m t i m e 58 old and n e w v e r si o n s 2 5
f o r g a m e i n s t r u c t i o n s7273, 1
r e a d y - m a d e b l o ck s 2 2 online/o f f line 24
speed
r e c o r d i n g y o ur own so unds18 8 , s e t t ing up 24 –5
371
e x p e r i m e nt i n g w i t h 8 8
remixing 208 scrolling
fall sp e e d 0 1 0
“ R e m o t e Co n t r o l ” m e s, s a7g 9e 1 s e l e c t i o n tool 62,16 0
G a m e S p e e d v a r 4i a1b72 le, 11
9,1202, 204 “ S e n s i n g ” b l o c k s 85
80
of haz ards65 1
“ r e p e at ” l o o p s “set c o l o r ” b 5l 1o, c k744
96
of launch 95
“repe at until” b l o c k 5 1 , 99,, 1 “setaFl ls p e e d ” b l o c38k 1
“spin” bl o6 7c k 1
2241 2, 12 4, 1 “set G r a v i t y ” bl ock10 380, 1
spooky features
r e v e r s e g r a v i t 0y1 165,5 “set s i z e ” b l o c k s, 6238,47
s p o r t s ,g a m 7e s 1 53
“ R e v e r s e Step” va r i a b l2e4 1 “set
a keT o f f S p e e d ” b l o c39k 1
c o l l i s i o n s73 t r e a s u r e h u n t s 30 G a m e S p4 e172e d, 11
“ s t a r t s o u n d ” b l o ck10183, 8 203 L a u n c h S p e e d 9 4, 95
see
tweak s h a c k s a n d t w ea k s s e t t i n g r a n g e0 1 4
see also
561 time 85
t a s k s , b r e a k i n g d own18 r o Tp i c au lnTe95s 1
d e l wsotnnkecmAg
A a d i t h y a n M o h a n , P r i y a n k a S h a r m a , a n d M a r k Silas for co d e t e s t i n g .