In preparation of the turtle system's use please download the file racketturtle.rkt and save it in your current working directory. Create a new file, copy and paste the code below to the very beginning of that file, and subsequently save it.
#lang racket
(require "racketturtle.rkt")
(define width 800) ; determines the window’s size (turtles’ playground)
(define height 800)
(define dc (start width height))
(define bobby (new turtle%
[tname ’Bob]
[xpos 400][ypos 500][direction 90]
[tcolor "YellowGreen"]
[tdc dc]))
(send bobby show!)Now you are ready to develop your procedures. The commands an arbitrary turtle understands are shown below. Syntactically, each turtle instruction matches the following pattern:
(send <turtle> <command> [<parameter>])| Command | The command's meaning |
| say-your-name | displays the full name of the turtle as initially given. |
| show! | shows the turtle at the current position. |
| hide! | The turtle disappears (from our sight only). |
| crow | The turtle crows which sounds like wringing a bell. |
| sleep n | The turtle sleeps for n milliseconds. |
| forward! n | The turtle moves n steps following the current viewing direction. |
| backward! n | The turtle moves n steps back following the opposite viewing direction. |
| right! n | The turtle turns to the right by an angle of n degree. |
| left! n | The turtle turns to the left by an angle of n degree. |
| pen-up! | causes the turtle to stop tracing beginning at the current position. |
| pen-down! | causes the turtle to continue tracing beginning at the current position. |
| pen-erase! | substitutes an eraser for the turtle's pen. |
| set-turtle-color! c | changes the turtle's color to c; possible values for c. |
| set-pen-color! c | changes the turtle's pen color to c; possible values for c. |
| clone | creates a clone of the turtle. |