Home
Project Folders
Teacher Resources
Student Resources
En ESPAÑOL
How Do I?
Vocabulary
MWForum
Site Map
Search
Our Team

ant hill 1 2 3 4 5 6
Ant Hill 3
Download
7 KB


Goal:   A line of ants follows the leader while you control its speed and direction.


Screenshot


Vocabulary:   towards, distance, * (multiplication sign)

Code
Shapes
Project Map

to go
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]
forever [clean
         compass, setpos [-195 -79]
         seth direction
         fd 43 bk 43
         settext1 heading]
end



Notes

A line of ants can play "Follow the Leader" as you control the speed and direction of the leader.

  1. Hatch three more turtles and shrink their size.

  2. Make a slider named speed.   Keep its minimum set to 0, and set its maximum to 20.

  3. In the go procedure, fd speed / 10 moves the ant forward one-tenth of the amount on the speed slider.

  4. T2, towards "t1 means, "Ant t2, point toward ant t1."   We also want t3 to point toward t2, and t4 to point toward t3.

  5. 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.




What If?
Try fd speed or fd speed / 5 to change the range of your ants' speeds.   Try changing the maximum on the speed slider.


Challenge
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?





© copyright 2001 - 2016  OpenWorld Learning.   All rights reserved.