math cats look at "follow a path"

screenshot of "follow a path" (inactive buttons)



This project lets you write commands to steer the turtle along a path to the house. Clicking on "create_a_path" sets up a new scene. After you type one or more commands in the white textbox, you click on "follow_the_path" to test them out. You can change the commands and try again as many times as you like until the turtle reaches the house while staying on the path. The turtle draws a thin black line as he moves along so that you can follow his trail.

You use three basic Logo commands to turn the turtle and move him along the path. Each command is followed by a number, which lets the turtle know how many degrees to turn or how many tiny steps to move forward. Here are a few examples, followed by explanations:

rt 75 (turn right 75 degrees)
lt 10 (turn left 10 degrees)
fd 200 (move forward 200 tiny steps)


If you own MicroWorlds and would like to create this project yourself, here are the procedures for making random paths through the woods and practicing Logo commands to steer the turtle:

* * * * * *
Procedures

(Please refer to the screenshot for the turtles, buttons, and textbox needed. The textbox is called "command_center." Create a house shape for your t1 turtle. Set t1's pensize to 32 and set its color to 23. Set t2's pensize to 2. Write the words "I'm home!" into a shape called "I'm_home!"
* * * * * *

to create_a_path
unfreezebg
clean
make "startx -258 + random 516
make "starty -100 + random 260
t2, setc 63 pd fill pu setc 9 setsh 0 setsize 40 setsh 0
t1, pu setx :startx sety :starty pd
newposition
t1, towards "t2 fd distance "t2
if (and ycor < 100 ycor > -50 xcor > -200 xcor < 200) [rt -90 + random 180 fd 10 + random 65]
newposition
t1, towards "t2 fd distance "t2
t2, setx :startx sety :starty pd
freezebg
command_center, ct
t2, seth 0
placetrees
when [touching? "t2 "t1] [t2, repeat 5 [setsh "I'm_home! setsize 40 wait 3 repeat 3 [setsize 30 setsh 0 wait 1 setsize 50 wait 1] setsize 40 wait 1] stopall]
end

to newposition
t2, setx -250 + random 500
sety -100 + random 260
end

to placetrees
ask [t7 t8 t9 t10 t11] [setx -270 + random 540 sety 0 + random 175 if colorunder = 23 [bk 100]]
ask [t3 t4 t5 t6] [setx -270 + random 540 sety 0 - random 100 if colorunder = 23 [bk 100]]
end

to follow_the_path
clean t2, seth 0
t2, pu setx :startx sety :starty pd
run command_center
end

to startup
command_center, ct
clean
t2, setsh 0
set "button1 "on? "true
end


copyright 2001 by Wendy Petti

back to math cats love MicroWorlds
MicroWorlds index
Go to the "follow a path" project! Get the MicroWorlds Web Player
so you can use the project