Starting From SCRATCH: An Introduction To Computing Science - Scratching The Surface
Starting From SCRATCH: An Introduction To Computing Science - Scratching The Surface
Acknowledgements
This resource was partially funded by a grant from Education Scotland. We are also grateful for
the help and support provided by the following contributors:
The contribution of the following individuals who served on the RSE/BCS Project Advisory Group
is also gratefully acknowledged:
Professor Sally Brown (chair), Mr David Bethune, Mr Ian Birrell, Professor Alan Bundy, Mr Paddy
Burns, Dr Quintin Cutts, Ms Kate Farrell, Mr William Hardie, Mr Simon Humphreys, Professor
Greg Michaelson, Dr Bill Mitchell, Ms Polly Purvis, Ms Jane Richardson and Ms Caroline Stuart.
Some of the material within this resource is based on existing work from the ScratchEd site,
reproduced and adapted under Creative Commons licence. The author thanks the individuals
concerned for permission to use and adapt their materials.
i
Starting from Scratch An Introduction to Computing Science
Contents
Introduction .................................................................................................... 5
What is a computer? ...................................................................................... 5
Types of computer ......................................................................................... 6
Parts of a computer ....................................................................................... 9
Hardware ..................................................................................................... 10
Software ....................................................................................................... 11
Programming languages .............................................................................. 12
Programming in Scratch ................................................................................ 13
1: Scratching the Surface ............................................................................... 15
All the world’s a stage .................................................................................. 15
Putting things in order ................................................................................. 17
Did you understand? .................................................................................... 18
Lazy or smart? .............................................................................................. 20
2: Story Time ................................................................................................. 21
Bugs .............................................................................................................. 22
Event-driven programming .......................................................................... 25
3: A Mazing Game ......................................................................................... 27
The Importance of Design ............................................................................ 27
4: Get the Picture? ........................................................................................ 35
Nesting ......................................................................................................... 36
5: Forest Archery Game ................................................................................. 43
Variables....................................................................................................... 46
Summary ...................................................................................................... 49
Scratch Project .............................................................................................. 51
Congratulations ............................................................................................ 60
iii
Starting from Scratch 1: Scratching the surface
Introduction
Watch the video introduction to Scratch. This will introduce you to Scratch and its
screen layout.
http://www.youtube.com/watch?feature=player_detailpage&v=jxDw-t3XWd0
2. Costumes/Backgrounds
Costumes are “outfits” for a sprite. The same sprite can have several costumes
and so be made to look completely different.
The stage can have different backgrounds which can be changed. Backgrounds
are just like costumes for the stage.
3. Sounds
These are sounds that sprites or the stage can use. Again, each sprite (or the
stage) can have many different sounds. Scratch lets you import (bring in)
recorded sounds or even record your own using a microphone.
Page 15
Starting from Scratch 1: Scratching the surface
This will go over the main elements within Scratch and take you through the task of
creating your first computer program. If you get stuck, go back in the screencast or ask
your partner.
This will show you how to create a simple tune in Scratch. If you get stuck, go back in the
screencast or ask your partner.
Did you know…? Frère Jacques is one of the best-known songs in the world. It is a French song about a
religious monk (“Brother John” in English) who has the job of ringing the morning bell
before the days of alarm clocks. Unfortunately, poor Jacques has overslept!
Task 3: My Tunes
Once you have completed Task 2, try creating a program that plays another simple song.
Choose one where lines of the music repeat, so you can use the repeat command.
Page 16
Starting from Scratch 1: Scratching the surface
For example, if you have several scripts, they will all get executed together
when the green flag is clicked.
x create a single script that includes the sprite movement blocks amongst the
play note blocks
x have separate scripts for the same sprite – one script plays the tune whilst the
other makes the sprite dance.
You can find another screencast (Dancing Queen) to give you some inspiration at
http://info.scratch.mit.edu/node/164 .
Make sure you create a tune, rather than just use a music loop, though!
Extension 2
Experiment by adding some other blocks to your program, such as the looks blocks e.g.
Page 17
Starting from Scratch 1: Scratching the surface
__________________________________________________________________
__________________________________________________________________
Why? _____________________________________________________________
__________________________________________________________________
Now try out the code yourself and see if you were right.
1.2 Now add a wait 1 secs block between the two move blocks. Describe what
happens now.
__________________________________________________________________
__________________________________________________________________
Write down what you think the user will see when the green flag is clicked.
__________________________________________________________________
__________________________________________________________________
Why? _____________________________________________________________
__________________________________________________________________
Now try out the code yourself and see if you were right.
Page 18
Starting from Scratch 1: Scratching the surface
1.4 In the stack of blocks below, how many times does the sprite move 10 steps?
__________________________________________________________________
1.5 A programmer wants the cat to dance to some music. However, the cat doesn’t
start dancing until after the music has finished!
Why is this?
__________________________________________________________________
__________________________________________________________________
Page 19
Starting from Scratch 1: Scratching the surface
1.6 In the example below, a programmer has chosen a piece of music (sound
“Xylo1”) to play during a game. However, when the green flag is clicked,
the computer just plays the first note of the music – over and over again!
__________________________________________
__________________________________________
1.7 In Extension 1: Dance Away, you made a sprite dance to a tune you created.
There were two ways you could do this:
x have a single script with the movement blocks amongst the play note blocks
x have separate scripts for the same sprite – one script plays the tune whilst the
other makes the sprite dance.
__________________________________________________________________
__________________________________________________________________
1.8 Make up a question like those from 1.1–1.6 and pass it to your neighbour.
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
Lazy or smart?
Computer programmers always look for shortcuts to make their life easier.
A good example is how we used a repeat block in Frère Jacques to repeat the same line
of music instead of having two identical sets of blocks. As well as looking neater, it also
means that you won’t make a mistake when creating a second set of blocks.
Do you think this makes programmers lazy or smart? (Hint: the answer is smart!)
You can make your life easier, too by spotting shortcuts like this.
Page 20