Goal: Draw a colored square.
Vocabulary: pd, setc (setcolor), fd (forward), rt (right), cg
We use words the turtle knows to teach it a new word: square.
You might like to type each command in the command center and hit Enter/Return after each line to see the turtle draw a square line by line. Then copy and paste the code into a square
procedure on the Procedures tab.
- Hatch a turtle.
- pd means "pen down" so that the turtle will draw a line wherever it moves.
- Setc means "set color." Setc 65 is a medium green.
- Fd 100 means, "Move forward 100 tiny turtle steps."
- Rt 90 means, "Turn right 90 degrees."
(Why 90 degrees? There are 360 degrees in a circle. The turtle ends up turning in a complete circle to come back where it started. To make a square with right angles, the turtle turns 1/4 of the way at each corner of the square. One quarter of 360 is 90. You might like to see what happens if the turtle turns a different amount. You could try a bit more than 90 degrees, or a bit less.)
- In the reset procedure, cg means "clear graphics." It erases everything drawn on the page and returns the turtle home (at the very center of the page), facing up.
- Make a button with the instruction square.
- Make a reset button that calls the reset procedure.
Try a different input (number) after each fd.
Try a different input (number) after setc.
Can you make a rectangle?
Can you make a square or a rectangle with a different color on each side?
On Your Own - Project Ideas
Can you make a simple colorful picture using just fd, rt, and the square procedure?