Category: Turtle
Rotates the turtle right by the specified angle. The turtle’s position remains the same.
turnRight() is one of the ways to change the turtle's orientation. When used with moveForward(), you can move, and draw with, the turtle anywhere on the screen.
// Rotate the turtle right 90 degrees (the default angle) from the current direction. turnRight();
Example: Step Draw a step with a right turn and a left turn.
// Draw a step with a right turn and a left turn. moveForward(); turnRight(); moveForward(); turnLeft();
Example: Letter W Draw the letter W with right turns only.
// Draw the letter W with right turns only. turnRight(150); moveForward(); turnRight(-120); moveForward(); turnRight(120); moveForward(); turnRight(-120); moveForward();
Example: Star Draw a 25 pointed star by first calculating the exterior angle turn necessary.
// Draw a 25 pointed star by first calculating the exterior angle turn necessary. var points = 25; var exteriorAngle = 180.0 - (180.0 / points); for (var i = 0; i < points; i++) { moveForward(200); turnRight(exteriorAngle); } |
turnRight(angle);
Name | Type | Required? | Description |
---|---|---|---|
angle | number | No | The angle to rotate right (90 degrees is default). |
No return value. Rotates turtle only.
Found a bug in the documentation? Let us know at documentation@code.org
Found a bug in the documentation? Let us know at documentation@code.org