AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Scripts that run together

Week 9 · Unit 4: Be a designer · 3 lessons
2

Build it block by block

Computing 3: Unit 4, pp. 60–78
GoalTurn the steps of an algorithm into Scratch blocks and say which group each block comes from.
New words
category · a group of blocks that do the same kind of job, such as Motioncostume · one of the pictures a sprite can wear, used to make it look as if it movessound · a noise that a sprite can play
Explanation

A good way to write a program is to write the algorithm first, as a list of steps. Then change each step into one block. The step that starts the program becomes a hat block from the Events group. Steps that move a sprite come from Motion, such as go to and glide. Steps that change how it looks, such as switch costume, come from Looks. A step that waits comes from Control, and a step that makes a noise from Sound. The last step, Stop, has no block: the script just ends.

whenspacekey pressedgo to x:-120y:-40start soundBubblesglide2secs to x:120y:60wait1secondsnext costume
Worked examples
StepInstruction
1Start when the space key is pressed
2Go to x: −120, y: −40
3Start the sound Bubbles
4Glide 2 seconds to x: 120, y: 60
5Wait 1 second
6Change to the next costume
7Stop
This algorithm for a fish becomes the six blocks in the picture: the hat block, go to, start sound, glide, wait and next costume. Step 7 (Stop) needs no block. So 7 steps become 6 blocks.
BlockGroup
when [space] key pressedEvents
go to x: y:Motion
next costumeLooks
switch costume toLooks
wait (1) secondsControl
start sound [Meow]Sound
Each block belongs to a group, so we know where to look for it in Scratch.
Costume firstwhenspacekey pressedswitch costume tocostume2wait1secondsWait firstwhenspacekey pressedwait1secondsswitch costume tocostume2
Order matters. In this script the costume changes first, and then the sprite waits. If we swap the two blocks, the sprite waits one second before it changes its costume, and everything looks different.
Class activity

Block cards (with a friend): write each step of an algorithm for a sprite on a strip of paper, such as “Go to x: 0, y: 0”, “Wait 2 seconds”, “Glide 1 second to x: 100, y: 0”. For each step, say which group the block would be in. Then lay the strips in order. This is your program. If you have a computer or tablet, build it in Scratch and run it.

Practice
1
Which group does each block come from? go to x: y:, wait (1) seconds, switch costume to, start sound.
Ago to x:0y:0Bwait1secondsCswitch costume tocostume2Dstart soundMeow
2
Write the blocks for this algorithm: 1 Start when the a key is pressed. 2 Go to x: 50, y: 0. 3 Glide 1 second to x: −50, y: 0. 4 Stop.
Your blocks????
3
How many blocks does the fish script in the explanation have, and where does the fish end?
4
Which step of an algorithm does not need a block?