Turtle Controls

The main purpose of any SeaTurtle program is to guide the turtle around the screen to form a drawing. This document explains how you can control the turtle.

Moving the Turtle

The turtle can be moved using the commands FORWARD and BACKWARD, which make the turtle move forward or backward respectively. After each command you must specify the number of units you want the turtle to move. For instance, the following program will make the turtle first move 50 units forward and then move 100 units backwards:

FORWARD 50
BACKWARD 100

If you try running the above program in SeaTurtle, you will end up with a single vertical line that is 100 units in length. This is because the 100 units the turtle moved backward overlapped with the 50 units the turtle moved forward, which results in the turtle being 50 units beneath its starting location.

Turning the Turtle

Turning the turtle is necessary for any drawing beyond a single vertical line. To turn the turtle, the commands RIGHT and LEFT are used followed by a number of degrees to turn right or left. The following program draws a square, by turning the turtle 90 degrees four times to form the corners of the square:

FORWARD 50
RIGHT 90
FORWARD 50
RIGHT 90
FORWARD 50
RIGHT 90
FORWARD 50
RIGHT 90

The last turn was not strictly necessary, but it ensures the heading of the turtle is the same as it was when the program started.

Moving without Drawing

When a SeaTurtle program starts, the turtle's pen is down. This means any movement of the turtle will leave a drawn line behind on the canvas. You can control whether the turtle is drawing or not with the commands PENUP and PENDOWN. The following program uses these commands to draw a 40 unit dotted line with 5 unit gaps:

FORWARD 10
PENUP
FORWARD 5
PENDOWN
FORWARD 10
PENUP
FORWARD 5
PENDOWN
FORWARD 10

With just these simple drawing controls (moving, turning, changing the pen) you can create a line drawing of just about anything. The rest of the SeaTurtle language is about using programmatic structures in concert with these simple commands to make more sophisticated programs and more interesting drawings.