Goal: Put the turtle back where it started.
Vocabulary: show pos, setpos, seth (setheading) -90
Be sure the turtle has the OnClick
rule as fd speed / 10
and is set to Forever
- Drag your turtle to the spot where you want it to start. In this sample, the turtle starts near the bottom right corner of the project page.
- Now we will find the coordinates for this position.
The computer uses two numbers to tell where your turtle is. 0 0 is the exact middle of your project page.
The first number is the "X coordinate" and tells how far your turtle is to the left or right of center. A negative number (such as -150) is left of center. A positive number (such as 150) is right of center.
The second number is the "Y coordinate" and tells how far your turtle is above or below the center. Positive numbers are above the center and negative numbers are below the center.
In the command center, type show pos and hit Enter/Return. On the next line you will see two numbers. Those are the X and Y coordinates for your turtle's position.
- Write a reset procedure.
In the sample procedure above, setpos [228 -92] means: "Place the turtle 228 tiny turtle steps to the right of center and 92 steps below center."
Use your turtle's coordinates (instead of these sample numbers) to place your turtle where you want it.
- Seth stands for "set heading."
Seth 0 points the turtle straight up, and seth 90 points him to the right.
Seth -90 points him to the left. There are 360 degrees in a circle. Seth 270 is another way to point the turtle to the left. (It is the same as saying either "2:45" or "quarter to 3" when looking at the hands on a clock.)
Try writing different numbers in the setpos command:
What happens if both numbers are positive?
What happens if both numbers are negative?
What happens if the first number is negative and the second number is positive?
Can you drag your turtle to another corner, find its position, and then change the X and Y coordinates and the heading in the reset procedure so the turtle will always return to this new position? (Move the pond to a different corner, too.)
Can you find the position of the center of the pond?
Can you change the instruction for the blue color so that the turtle will move into the pond, wait a little bit (wait 20 or another number) or move a little bit, and then return to its starting position?
On Your Own - Project Ideas
Try drawing a different scene with a wide path and write a reset procedure so that the turtle is ready to start at the beginning of the path.