GoalUse the forever block in a Scratch program and say what it does when the green flag is clicked.
New words
forever block · a Scratch block that repeats the blocks inside it until you stop the programcostume · one of the pictures a sprite can wearsprite · a character or object in a Scratch program
Explanation
In Scratch, the forever block is in the Control group. The blocks inside its mouth repeat over and over until you click the red stop button. A sprite can have many costumes, which are slightly different pictures of the sprite. The block “next costume” changes to the next picture in the list, and after the last picture it goes back to the first one. Put “next costume” and a short wait inside a forever loop, and the sprite seems to move. Without the wait, the pictures change so fast that you cannot see them. A forever block has no notch at the bottom, so no block can be fixed underneath it.
Worked examples
A moon sprite has 3 costumes: new moon, crescent moon and full moon. It starts on costume 1. Each time “next costume” runs, it moves on one costume and goes back to the first after the last. After 4 uses, the moon shows the crescent.
A heart sprite beats like a pulse. It is big for 0.3 seconds, then normal for 0.3 seconds, and again and again. One full round takes 0.6 seconds, so in 3 seconds it makes 5 rounds.
One forever loop never ends, so a second job cannot wait underneath it. To do two jobs at the same time, use two scripts that both start with “when green flag clicked”. Here the sprite changes costume and turns at the same time.
Class activity
Be the loop (with a friend): draw a flower on three small cards: a bud, half open and fully open. Stack the cards with the bud on top. One person is the forever block. Show the top card for two counts, then move it to the bottom of the stack so the next card shows. Keep going until your partner calls “Stop!”. Before you start, guess which card will be showing after 7 changes, then check. If you have a computer or tablet, put “next costume” and “wait” inside a forever block for a sprite with several costumes.
Practice
1
A plant sprite has 3 costumes and starts on costume 1. Which costume shows after “next costume” has run 5 times?
Costume 3 (it goes 2, 3, 1, 2, 3).
2
How long does one full round of this loop take?
1 second (0.5 + 0.5).
3
Why does a loop that changes costumes need a wait block?
Without a wait, the costumes change too fast to see.
4
Which script keeps changing costume until you stop it? What does the other script do?
Script B. Script A changes the costume once and then ends.