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

Sprites that interact

Week 1 · Unit 1: Be a designer · 3 lessons
1

One sprite follows another

Computing 5: Unit 1, pp. 8–19
GoalWrite an algorithm and a program in which one sprite follows another sprite.
New words
sprite · a character or object in a Scratch project; each sprite has its own codeinteract · to affect each other, for example when one sprite follows or talks to anotherrandom position · a place on the stage chosen by chancepoint towards · a block that turns a sprite to face another sprite or the mouse pointer
Explanation

A Scratch project can have many sprites, and each sprite has its own scripts. When two sprites affect each other, we say that they interact. In a following game, one sprite is the leader and wanders about. The other sprite is the follower. It turns to face the leader and then glides to it, again and again. The two sprites need two different algorithms, and both start when the green flag is clicked. The follower’s blocks have a drop-down list. Once the leader is in the project, its name appears in that list.

Butterfly (leader)whenclickedglide3secs torandom positionrepeat6Bee (follower)whenclickedpoint towardsButterflyglide2secs toButterflyrepeat12
Worked examples
The butterfly repeats its glide 6 times, and each glide takes 3 seconds. So the leader’s script takes 6 × 3 = 18 seconds. After that the script ends and the butterfly stays still.
x 240−240y 180−180butterflybee
The bee repeats 12 times, and each glide takes 2 seconds. So the follower’s script takes 12 × 2 = 24 seconds. For the last 6 seconds the butterfly is not moving, so the bee reaches it and stays on it.
whenclickedpoint towardsButterflyglide1secs toButterflyrepeat12
A shorter glide makes a quicker follower. If the bee glides for 1 second instead of 2, the same 12 repeats take only 12 × 1 = 12 seconds.
Class activity

Leader and follower (with a friend, indoors or in a safe play area). The leader walks to any spot, stops, and counts to three. The follower stops, turns to face the leader (point towards) and walks to the leader’s spot (glide). Do 6 rounds. Then write the follower’s algorithm as numbered steps, using the words ‘point towards’, ‘glide to’ and ‘repeat’. If you have a computer or tablet, build both scripts in Scratch with two sprites of your choice and run them.

Practice
1
A kitten follows a ball of wool. Which block makes the kitten turn to face the wool? How many times does it turn to face it?
whenclickedpoint towardsWoolglide1secs toWoolrepeat8
2
A ball script repeats 5 times with a 4-second glide. A dog script repeats 8 times with a 3-second glide. Which script is longer, and by how many seconds?
Ballwhenclickedglide4secs torandom positionrepeat5Dogwhenclickedpoint towardsBallglide3secs toBallrepeat8
3
A pupil leaves out ‘point towards’ and keeps only ‘glide to’. Will the follower still reach the leader? What is different?
4
Put these blocks in the right order for a follower script: glide (2) secs to (Hen); when the green flag is clicked; repeat (10); point towards (Hen).