Goal: Steer an ant with a slider.
Vocabulary: fd (forward), / (division sign), forever, seth (setheading), setsize
t1, forever [fd 1 / 10 seth direction]
This project uses a slider to control the direction that a tiny turtle (ant) moves.
- Hatch a turtle. In the command center, type:
and hit Enter/Return. This shrinks your turtle to a tiny size so that it looks like an ant.
- Make a slider named direction. Sets its minimum to -180 (a negative number) and set its maximum to 180.
- In the go procedure, forever means, "Do what is in the brackets over and over again."
- Fd 1 / 10 means, "Move forward one-tenth of a tiny turtle step."
The turtle will move forward slowly.
- Seth stands for "set heading."
Seth 0 points straight up.
Seth 180 points straight down.
Seth -90 points straight to the left.
Seth direction means, "Set the turtle's heading to the value of the direction slider."
Since the direction slider is set to a minimum of -180 and a maximum of 180, the little ant can point any direction in the circle. Moving the slider to the left (into the negative numbers) angles the ant toward the left, and moving the slider to the right (past the center) angles the ant toward the right.
- Spill green paint to make "grass" for the ant.
- Make a go button that calls the go procedure, and try steering the ant!
Can you steer the turtle in a rough circle around the sugar? Try setting your slider to a minimum of 0 and a maximum of 360. Compare.
Try different numbers after fd, such as 1 / 2 or 1 / 100 or 1 or 5. What is a good speed for your ant?
Can you change the name on the slider and change the procedure so that you can still steer the turtle?
On Your Own - Project Ideas
Can you program the color white so that something happens when the ant touches it?