Goal: A line of ants follows the leader while you control its speed and direction.
Vocabulary: towards, distance, * (multiplication sign)
forever [t1, fd speed / 10 seth direction
t2, towards "t1 fd 1 / 20 * distance "t1
t3, towards "t2 fd 1 / 20 * distance "t2
t4, towards "t3 fd 1 / 20 * distance "t3]
compass, setpos [-195 -79]
fd 43 bk 43
A line of ants can play "Follow the Leader" as you control the speed and direction of the leader.
- Hatch three more turtles and shrink their size.
- Make a slider named speed. Keep its minimum set to 0, and set its maximum to 20.
- In the go procedure, fd speed / 10 moves the ant forward one-tenth of the amount on the speed slider.
- T2, towards "t1 means, "Ant t2, point toward ant t1." We also want t3 to point toward t2, and t4 to point toward t3.
- Fd 1 / 20 * distance "t1 means, "Move forward one-twentieth of the distance to ant t1."
This way, each ant will be constantly pointing toward and moving toward the ant in front of it without ever catching up to it.
Try fd speed or fd speed / 5 to change the range of your ants' speeds. Try changing the maximum on the speed slider.
Can you adjust the go procedure so that the ants are always closer together? Always farther apart?
On Your Own - Project Ideas
Can you make a different type of character follow a leader, such as birds or balloons or letters of the alphabet?