Goal: A spider moves as it grows.
Vocabulary: fd (forward), setpos, seth (setheading)
We are adding fd 5
(or another number) into the grow
procedure. The spider will move forward as it grows.
- Place the spider (turtle) at the top of the web.
- Next we need to set the turtle moving in the right direction. One way to do this is to return him to a turtle shape: in the command center, type
and hit Enter/Return.
Drag the turtle's head until it is pointing in the direction you want it to go, then put the spider costume back on the turtle.
- Another way to change the turtle's direction is to type seth 130 (or another number) in the command center, and hit Enter/Return.
Seth stands for "set heading."
Seth 0 is straight up.
Seth 90 turns the turtle 90 degrees to the right.
Seth 130 points the turtle at an angle heading down and to the right.
- In this sample grow procedure, the spider increases his size by 2 as he moves forward and grows. You may try other numbers.
- The reset procedure returns the spider to the top of the web again.
Setsize 10 makes the spider tiny again.
- Setpos [-173 134] tells the spider exactly where to go on the page. You will probably want to use different numbers, depending on where you place your spider:
Setpos stands for "set position," and it is always followed by two numbers. ( Setpos [0 0] is the exact middle of the page.)
The first number tells the turtle how far left or right to go. A negative number moves the turtle to the left of center, and a positive number moves it to the right.
The second number tells the turtle how far up or down to go. A negative number moves the turtle down, and a positive number moves it up.
You can drag your spider exactly where you want it to go, then find out where it is by typing show pos in the command center and hitting Enter/Return. The computer will output two numbers on the next line. Those are the two numbers you should place inside the brackets of your setpos command.
Try having the spider move forward by a different amount.
Try increasing the spider's size by a different amount.
Can you place the spider in the top right corner of the web and make the spider move down and to the left while it is growing?
Can you change the reset procedure to send the spider back to this new position on the web?
On Your Own - Project Ideas
Can you use recursion to animate another creature to grow as it moves?