2. What is Scratch?
With Scratch, you can program your own interactive
stories, games, and animations.
It helps you to learn to think creatively, reason
systematically, and work collaboratively — essential
skills for life in the 21st century.
Scratch is designed especially for ages 8 to 16, but is
used by people of all ages. Millions of people are
creating Scratch projects in a wide variety of settings,
including homes, schools, museums, libraries, and
community centres.
3. Today’s learning objective is simply to dive into Scratch and see what it can do on
a very basic level!
It is important that you follow what is happening. It is part of your responsibility
to take control of your learning. Work effectively as part of a team, when
required, plan ahead and get on with it.
Be resilient when you find something difficult. Stick at it and you will soon learn
how to overcome those difficulties. Have a positive attitude and find interest in
what you are doing.
Be resourceful. Manage your learning in different ways. Use your imagination and
take risks. Ask good and imaginative questions.
Be a reasoning learner who can choose the best method, say which is better and
why, gather all the evidence and take time to do something properly.
Finally be reflective. Learn from your mistakes and listen to different
opinions. Ask why? And most importantly stay calm!
4. Parrot Shooter
This is a nice little game to start off with.
You will be taught to make parrots fly on
random paths, then shoot them and make
them disappear.
For good measure you will be shown how
to keep the score and set a timer to shoot
all the parrots within.
6. Open Scratch and you will see the following window
with a brief note on the various functions.
Sprite Preview
Sprite Editor
Sprite Selection and
Creation
Tool Box
7. Tool Box is like a
bucket of Lego; it
provides single
script blocks for
building combo
script blocks.
Tool Box
13. We now need to find our flying parrot so,
click on the choose new sprite from file.
Double click on Animals in the new window
that opens.
14. Scroll down until you find parrot1-a.
Click on it and then press the OK button.
15. As you can see the parrot is a bit too big for
our game area (the white space around the
parrot) and even Mr Moore could shoot
something that big!
Select the Shrink sprite
button. Move it onto
the parrot and keep on
clicking until the parrot
is about the right size.
16. Now we need the parrot to fly around the
screen. If we press the green flag then this
would normally start our program script
but, as we have not written any script yet,
nothing will happen.
17. Make sure that the parrot, Sprite1, in
the sprite selection and creation
window is selected.
Go to and select the Control tab in
the tool box area
then
drag the
command to the
Sprite editor in the
Scripts area.
18. The next step is to get the parrot to move so, as
movement is motion, select the Motion tab and
drag the command into the scripts
area and attach it underneath the
command.
Hopefully you will begin to notice that
certain commands will slot nicely into
others if they complement each other.
Just like a jigsaw puzzle.
19. Now press the green flag and see what happens
to the parrot. Press it again,
Not very sensible to have to keep on pressing
the green flag – especially when you are playing
the game!
So, the next step is to make the parrot move
forever.
20. In the scripts area uncouple the
command from the
Click on the tab
Select the command and
Couple it with
Slot the under forever.
21. Now run your program
by clicking the green flag.
22. Wow! That was amazing NOT!!!!
Now let’s get the parrot to bounce back should it
hit an obstacle (i.e. the wall at the edge of the
sprite preview window in this case).
Click on the tab
Towards the bottom select and slot
this this just under
Press the green flag.
23. A bit better but the parrot looks as though it
doesn’t know which way up to fly.
Let’s remedy this before we carry on. Stop the
program script.
Above the Scripts tab there are three little
command buttons just to the left of the parrot.
Select the middle button that says only face left-
right
Run the program
24. Before we carry on let us save what we have done
so far.
1.Stop the program.
2.Go to File and choose Save as from the drop-
down menu
3.Click on the Computer tab on the left and
choose letter Y or
4.Choose Year 6, your class, your name and save
the program as Parrot Shoot Game.
25. Now we need to add some randomness into the
game otherwise shooting the parrot would be too
simple.
Let us look at some of the possibilities that we now
have and choose the best one/s for our game.
Let us see what happens when we, say, change
direction by 15 degrees after each 10 steps.
26. Make sure that the tab is selected.
Find
And slot it under
Run the program.
27. A bit better but our poor parrot seems to be going
in circles. Not surprising as 15 degrees seems to be
quite a lot.
Change the 15 degrees to 5 and see what happens.
28. Slightly better still but eventually the parrot ends
up going in a predictable pattern – not good for
games lovers!
boring
29. Now you change the move 10 steps to move 20
steps and see what happens.
Well, the parrot moves faster but, again, the
eventual pattern is predictable. So let us now add
some randomness into our parrot’s movements.
30. Randomness in computer programming uses the
operators function. So, choose the green
operators tab just below the control tab you have
been using up to now.
About a quarter of the way down the list you will
see the instruction.
Drag one of these into the box that says ‘20’ in
the
Change the numbers 1 to 10 to 10 to 30
31. Do the same as before but this time for the
command. Do not change the
values 1 to 10 but leave them as they are.
Run the program.
32. Tea break (teachers only). Time to save your
work and ask any questions about anything you
do not understand.
34. Having only one parrot in the game to shoot
wouldn’t be very exciting so we are going to add
some more.
The easiest way to do this is to right click on our
parrot and choose the duplicate command from the
menu.
Do this so that there are (say) 5 parrots on the
screen. Move them about so they are not on top of
each other.
35. Now, besides copying the graphic – Sprite 1 to
Sprite 5
you will also notice that if you click on each of the
sprites it has also copied the code. This re-use of
code in computer programming is very import and
useful.
Now run your program.
36. Lovely background! It’s not very often that you see
parrots flying around the Arctic or Antarctic so we
now need to choose a suitable background image.
37. The background aspect of our game is called the
Stage.
Click on and you will see in the Scripts area
that there is no code but, at the top, are three tabs
click on Backgrounds
38. Underneath the Backgrounds tab you will see that
you could, if you so wanted, Paint your own
background, Import one that has been saved
previously or even import one from your Camera.
Today we are going to import one that has
already been saved.
So, click on the Import tab.
39. Now choose the Nature folder and then select
the Lake background.
40. Now we are going to need a target (cross-hair)
with which to shoot our parrots. We could import
one but instead we are going to paint our own.
Firstly - click on the Paint new sprite icon
42. As with most paint programs, to get a perfect circle
you just hold down the key on your
keyboard and draw at the same time.
43. Now we need to draw the cross-hair on our target
by using the Line tool and choosing Black.
It should now look like this …
44. When you are happy with your target and
crosshair click the OK button.
If your target is a little on the large size then shrink
it down.
45. The next step is to get the target to move around the
screen. There are many ways to do this but to make it
simple at this stage we are going to use the mouse
pointer.
In the Scripts area of the target drag in a
command, go to the tab and then drag
the instruction underneath it.
After the words go to there is
a black down arrow. Select this and
choose mouse-pointer at the top.
46. As soon as you have run the program you will
notice that the target moves to the mouse-pointer
only once and then stops.
Why do you think that is the case and what
command do you think we need to use to resolve
the dilemma?
47. Well, who suggested we use the Forever
command?
Well done if anyone did. Now do it and run the
program.
48. Coffee break (teachers only). Time to save your
work and ask any questions about anything you
do not understand.
49. Stage 3
Making the parrots disappear when shot
and then bringing them back to play again.
50. Now we come to the actual shooting aspect of the
game. The basic idea now is that when you shoot
the parrot it disappears.
We will think about, later on, what to do when all
the parrots have disappeared.
The first thing we need to decide on is what key to
use on the keyboard to shoot the parrot to keep
things simple we will use the …
51. Click on the first parrot, Sprite1
Select the tab
Find the command and place it
somewhere underneath your previous script
52. We now need to think carefully about what we
want our program to do. Simply, we want the
parrot to disappear (hide) when the spacebar is
pressed and the parrot is touching the target.
So, our code should recognise that when the space
bar is pressed,
if the parrot is touching the target, then it
disappears (hides).
53. Select the tab and
Drag the command onto
Now select the tab and
Drag the top command, , into the
space after the if command
54. Now we need to decide what the if command
refers to. Simply, if the first parrot (sprite1) is
touching the target (sprite 6 in this case) then that
parrot will disappear (hide).
So after touching we need to choose Sprite 6 from
the drop-down list.
55. The final part of this line of code is to tell the parrot
to disappear (hide) if it is touching the target when
the spacebar is pressed.
Select the tab and drag the
instruction into the blank space under the if
command.
Run the program and try it out.
56. Well, we have sorted out what happens to the
Sprite1 parrot but we need to do the same for the
other 4. Luckily we are able to use the same coding
for Sprite1 for the other 4 Sprites (parrots).
Make sure Sprite1 is selected…
57. Now follow these instructions VERY carefully!
In the Scripts section of Sprite1, click on the
instruction and DRAG it on top
of Sprite 2.
Sprite 2 should have a GREY GLOW about it when
you let go of the commands you want to copy.
Do exactly the same for the rest of the parrots
58. Check to make sure that the same lines of code
have been copied across to all the parrots by
selecting each of them in the Sprites window.
Run the program and play the game.
59. Some of you may have noticed that even
when you have shot all the parrots they are
still flying in the background
Look here to see each of their movements.
We haven’t killed the parrots – we’ve just
hidden them.
60. So, how do we get the parrots back again once they
have been hidden?
Simple.
Select the first parrot (Sprite1) and from the
tab drag in another command.
From the drop-down menu arrow after space
choose the letter a.
61. Now we want to show the parrots once the letter
a is clicked on the keyboard so go to the
tab and join the piece of code to
Now copy the new code to the other 4 parrots
and run the game using the a key to get them all
back.
62. Bathroom break (teachers only). Time to save
your work and ask any questions about
anything you do not understand.
64. When designing any game it needs to decided at
the outset what the scoring system is to be.
For our game we are going to say that …
• Every time you press the spacebar you lose 1
point
• Every time you hit a parrot you get 10 points
• Maximum score 50
65. The first thing we need to do is to create what is
called a variable.
Make sure that Sprite1 is selected.
Then click on the tab.
66. You will see underneath the variable section there
are only two options…
Click on Make a variable and give it the name
score
Leave the For all sprites button selected as this
variable will apply to all parrots
67. Hopefully, those of you who are looking carefully
will have noticed that a score board has
appeared in your play area.
68. Earlier on we said that every time you press the
spacebar then you lose 1 point. So, we need to
modify the code structure …
As soon as the player presses the space key we
want 1 point to be deducted so we need to split the
code when space key pressed and if touching
Sprite6
69. If you are limited for
space between each
block of code then move
them down the screen
like that to the right.
split code
70. Under drag a block
For the mathematicians amongst you, you will
notice that we are adding 1 each time we press the
spacebar rather than taking 1 away. So, change the 1
to -1.
The next part is similar to the above. If you
remember we said earlier on that Every time you hit
a parrot you get 10 points so we need to change if
touching sprite 6 code as well.
71. Under the hide piece of code we now need to
add the same piece of code as previously but this
time adding 10 each time. It should now look like
this once the code blocks have been joined back
together again …
72. This part is intentionally to show you what happens
when you do not do your initial planning correctly.
This is just the same as what happens in planning a
Science investigation or a design and technology
activity.
Bad planning means EXTRA work! Coding is no
different and can add many hours of time to
computer programming if the project is not
minutely planned from the outset.
73. The code we have just amended now needs to be
copied into that of the other 4 parrots. BUT, we
already have the old code still in each of them.
So you will have to go to Sprites2, 3, 4 & 5 and
delete the old code by dragging it to the window
on the left.
drag out
old code
74. Now you need to copy the new code from
Sprite1 into the other 4 parrot sprites.
drag new
code
75. Now play the game. What do you notice about
the score every time we press the space bar?
Hopefully you will have noticed that the score
doesn’t drop by 1 but by 5! This is because we
have the same command for each of the 5 parrots
which means if we press the space bar we lose 5 x
1 off our score.
To remedy this change the to -0.2
each time and do this for all
parrots
76. Nearly there!
Now some of you will have noticed that when you
restarted the game it carried on where you left
off!
The next step is to return the scoreboard to zero
when a new game is started.
Make sure that the first parrot is selected (Sprite1)
77. Split the and code blocks
and drag in the variable to fill the space
between them. Reassemble into one block.
78. Finally some of you will again have noticed that
every time you make a hit the score only goes up
by 9 and not 10 as programmed. This is because
you do gain 10 but also lose 1 for using the space
bar!
To make the game fair change the
to
Do the same for all 5 parrots.
Now play the game.
79. Game too fast for you?
Look at the coding and see which of the code
blocks you could change to slow the parrots
down.
Answer on next slide for those who are unable
to work it out.
80.
81. Exercise break (teachers only). Time to save
your work and ask any questions about
anything you do not understand.
82. Stage 5
Making it tough with a timer. Can you work
out how to get the "game over" message
up?
83. Last bit! This time we want to make the game
even trickier still.
We are going to make it so that the game finishes
after 20 seconds!
This means that you only have 20 seconds to gain
a score of 50 or more!
84. To get the game to finish after
20 seconds we need to use a
timer. There is a timer under
the Sensing tab but this is not
suitable for our game. This
timer just keeps on running
from 1 onwards.
We need a timer that will count
down from 20 to zero and then
stop the game.
85. The first thing we need to decide on is where to
put the timer. In this case it is more convenient to
put it with the background (stage).
So, click on the stage icon where you will find no
scripts at the moment.
We are now going to use another variable so click
on the tab and choose .
When the dialogue window opens name the new
variable clock then press OK.
86. You will now see the clock appear under the
scoreboard in the players window.
If you do not want to have the clock
shown then deselect the clock option
in the variables panel on the left.
Alternatively, drag the clock to the right-hand side
of the players window (or wherever else you want
it)
87. Coding for the clock.
What we want to happen when the game starts is
to set the clock to 20 so that it will countdown
until zero.
Drag in the command under the
tab and then, under the tab
drag in and change the zero to 20.
88. Now, as we have not thought through this aspect
of the coding in detail, we are going to follow our
instincts to what has to be done next (not the
right way to do it but hopefully we will learn by
our mistakes next time).
We want the clock to count down 20 times until it
reaches zero.
89. To do this we will now add in the
command from the tab and change the
repeat value to 20
Under the repeat 20 instruction we want to add
the command found under the
tab.
As we are counting down we need to change the
variable to -1
90. Now run your program and watch the clock. Did
you see how fast it went? It counted down really
fast. What we forgot to do was to tell the clock to
wait 1 second after each repeat command.
So, go to the tab and insert the
line of code. Where do you think it goes? Have a
go.
91. If you put the instruction under the
line of code you will notice that the
clock immediately takes 1 off. What you need to
do is put the instruction just before the
line of code.
Run your program.
92. This is the final stretch of coding for the Shoot the
Parrot game.
If you remember a few slides back we wanted the
game to stop when the clock reached zero.
If you run the game watch the clock and see what
happens when the clock reaches zero.
This should only take you 20 seconds – I wonder
why…
93. As you will have noticed, nothing happened. The
game just carried on. What we want to do now is
to sort out some code so that when the clock
reaches zero the game stops.
This is very simple. Go to the tab and
insert the command at the very end.
94. So you have it. Your very own
Parrot Shoot Game.