Making a simple animation program
Animation comes from French for “bringing to life”: pictures or objects appear to move. On a computer this is done by changing a sprite’s position in many small steps or by switching its costumes quickly. A script usually starts with the “when green flag clicked” block from Events, with Motion blocks snapped below: “move 10 steps”, “turn 15 degrees”, “point in direction 90”, “go to x, y”. Direction is given in degrees: 0 is up, 90 is right, 180 is down, –90 (that is, 270) is left. The “if on edge, bounce” block sends the sprite back from the stage edge. The Repeat block runs the commands inside it a set number of times, and Forever repeats until stopped. For example, “repeat 5: move 20 steps” makes the sprite go 5 × 20 = 100 steps in all. Run the script, watch the result and change the numbers if needed.
In training a coach says “do ten sit-and-stands” rather than saying it ten separate times. Repetition gives a short, exact instruction. The “repeat” block in a program does just that.
A programmer writes repeated jobs briefly, a coach gives exercises as repeats, and an animator builds movement with a loop.
Write a short instruction using repetition (such as “clap, 5 times”) and let a friend carry it out.
“Living script”: in groups, one pupil acts as the “sprite” and moves around the room following commands on the board (steps, turns, repeat). Then the script is tested in Scratch.