GoalUse a repeat block inside an animated story and work out what happens and when.
New words
opening line · the first words of a story, said once before the loopone-off step · a step that happens once, so it stays outside the looptiming · how long each part takes
Explanation
Stories are full of things that happen again and again. A fisher casts a net, a frog hops along a path and a bird flaps its wings. In a Scratch story, the opening line and the ending line each happen once. The part that repeats goes inside a repeat block between them. When you read a story script, trace it part by part. Work out how long each part takes and which costume the sprite wears. The “say” block with a time waits until the time is over. The “next costume” block takes no time at all. Never put the ending under a forever block: the script would never reach it.
Worked examples
Time
What happens
Costume at the end
0–2 s
says “Time to fish!”
1
2–4 s
loop trip 1
2
4–6 s
loop trip 2
3
6–8 s
loop trip 3
1
8–10 s
says “Home at last!”
1
The fisher has 3 costumes and starts on costume 1. This table traces the whole story. The story takes 2 + 3 × 2 + 2 = 10 seconds. After three “next costume” blocks the fisher is back on costume 1.
A frog hops along a path. It says “Ready?” for 1 second, hops 5 times, 20 steps each, with half a second between hops, and then says “I made it!” for 1 second. It moves 100 steps and the story takes 1 + 5 × 0.5 + 1 = 4.5 seconds.
Loop block
What happens next
repeat (3)
the story goes on to the last line
forever
the story never reaches the last line
Compare what happens after the loop. With a repeat block the story reaches its last line. With a forever block it never does, and there is no room to attach a block underneath it.
Class activity
Act a story (with family): think of a short story with something that repeats, such as a fox that creeps forward 4 steps. Write the script on paper: one line for the start, one line for the loop with its number and one line for the end. Decide how many seconds each part lasts. Then act it out and count the seconds aloud. Does the real time match your plan? Change the number in the loop and act it again.
Practice
1
A baker sprite has 2 costumes and starts on costume 1. How many times does it say “Knead!”, which costume does it wear at the end, and how long does the script take?