Pencil Code Reference > rt

 

rt turns the turtle right

rt pivots the turtle clockwise (rt stands for "right turn").

The turn is measured in degrees.

rt 90

Notice that the turtle will not actually move in the new direction until you tell it to move forward with fd.

Drawing Angles

When using a pen, putting rt between two fd moves can draw an angle.

pen purple
fd 100
rt 120
fd 100

Notice that the angle used by rt is the exterior angle. The interior angle added to the exterior angle will be 180. For example, the 60 degree interior angle drawn by the program above corresponds to the 120 degree exterior angle swept out by the turtle.

Turning an Upside-Down Turtle

rt turns right from the turtle's point of view, so if the turtle is facing downward, when it turns right from its point of view, it will end up facing left from your point of view. The demo below can be clicked a few times to show different starting directions.

turnto random 360
pen orange
fd 100
lt 100
fd 100

Drawing Curves

rt can also be used to draw curves by using a second argument. Read the reference page on arcs.