Starting From SCRATCH: An Introduction To Computing Science - Story Time
Starting From SCRATCH: An Introduction To Computing Science - Story Time
Story Time
LEARNER NOTES
Starting from Scratch An Introduction to Computing Science
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 2: Story Time
2: Story Time
Once you have done this, try creating a joke of your own – for example, a “Knock,
Knock” joke – that uses two characters like the one in the example.
Pay attention to when each character (sprite) “speaks” by planning out the code,
including speaking and waiting, like the one below.
Girl Boy
Say “Hey, I’ve got a joke!” for 3 secs Wait 3 secs
Wait 3 secs Say “Okay – let’s hear it!” for 3 secs
Say “My dog’s got no nose” for 3 secs Wait 3 secs
Wait 3 secs Switch to costume of boy shrugging
Say “How does it smell?” for 3 secs
Say “Terrible” for 2 secs Wait 2 secs
Switch to costume of boy laughing
Say “<Groan>” for 3 secs
2.1 Write down any problems you had and what you did to overcome them.
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
Page 21
Starting from Scratch 2: Story Time
Keep it simple with only two or three actors (sprites). Write a script on lined paper, with
each actor’s lines side-by-side, as shown in the previous example.
Hint: You can use the broadcast block to let a sprite trigger an event, such as a scene
change e.g.
You can find another screencast (Haunted Scratch) to give you some inspiration at
http://info.scratch.mit.edu/node/165
Hint: you will have to start your sprite actors at the edges of the screen and use the
show and hide blocks to make them appear at the correct place every time.
Bugs
A bug is an error which stops your code working as expected. There are two main types
of bug which can occur in a program:
● Syntax error
This happens when the rules of the language have been broken e.g. by mis-
spelling a command. Syntax errors usually stop the code from running.
Languages like Scratch provide code in ready-written blocks, so you won’t make
many syntax errors.
● Logic error
This means your code runs, but doesn’t do what you expect.
Unfortunately, it’s still possible to make logic errors in Scratch!
Finding and fixing these errors in a program is known as debugging.
Page 22
Starting from Scratch 2: Story Time
2.1 The program below shows the scripts for two sprites to tell a joke to each
other. Why would this program not work?
Girl Boy
__________________________________________________________________
__________________________________________________________________
2.2 The program below shows the scripts for two sprites to tell a joke to each
other. Aside from being a terrible joke, what is wrong with this program?
__________________________________________________________________
__________________________________________________________________
Page 23
Starting from Scratch 2: Story Time
2.3 The program below shows the scripts for two sprites to tell a joke to
each other. Why would this program not work?
Girl Boy
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
2.4 Now make up a “buggy” question of your own and pass it to your neighbour.
Page 24
Starting from Scratch 2: Story Time
Event-driven programming
Some computer programs just run and continue on their own with no input from the
user e.g. your program to play a tune.
However, many programs react to events (things that happen), such as:
● the click of a mouse or press of a key;
● the tilt of a game controller;
● a swipe of a smartphone screen;
● a body movement detected by a motion-sensing controller such as a Kinect
It is also possible to create your own events in Scratch using the broadcast command.
2.4 Look at the Scratch environment and write down some other events or conditions
that Scratch programs can react to.
Hint: the Control and Sensing blocks are a good place to start.
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
Page 25