Lessons 29 · 1 lessons · D.T. Kamaltdinova, D.M. Sayfurov. Informatics and Information Technology, Grade 5 (general editor F.M. Zakirova). “Nashriyot uyi Tasvir”, Tashkent, 2020
29
Making a simple animation program
Textbook: pp. 94–97
GoalExplain what animation is; build a simple script from motion, turn and repeat blocks and move a sprite across the stage.
New words
animation: making pictures appear to move · animatsiyarepeat block: runs the blocks inside it several times · takrorlash blokidirection in degrees: 0 up, 90 right, 180 down, –90 left · yo‘nalish (gradus)if on edge, bounce · chetga yetsa, qayt
Explanation
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.
Worked examples
Script: when green flag clicked → forever: move 10 steps; if on edge, bounce. The cat goes back and forth across the stage; it crosses the 480-unit width in about 48 repeats of 10 steps.
A spinning sprite: “repeat 24: turn 15 degrees”. 24 × 15 = 360 degrees – the sprite makes one full turn.
Class activity
“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.
Practice
1
What is animation and how is it made on a computer?
Pictures appearing to move; by moving a sprite in small steps or changing its costumes.
2
Which directions are 0, 90, 180 and –90 degrees?
Up, right, down, left.
3
How many steps in all does “repeat 8: move 15 steps” make the sprite go?
120
4
Why is Repeat sometimes better than Forever?
Repeat stops after a set number of times so the movement is controlled; Forever never stops by itself.