Category: Turtle
Moves the turtle backward a given number of pixels from the current direction.
Sometimes it is more natural to tell the turtle to moveBackward() in a straight line instead of telling the turtle to moveForward() a negative number of pixels.
// Move backward 25 pixels (default) moveBackward();
Example: Letter L Draw the letter L with moveBackward() and turnLeft() only.
// Draw the letter L with moveBackward() and turnLeft() only. moveBackward(); moveBackward(); turnLeft(); moveBackward();
Example: Long Line Move backward 200 pixels.
// Move backward 200 pixels. moveBackward(200);
Example: Barbell Draw a barbell using moveForward(), moveBackward() and dot().
// Draw a barbell using moveForward(), moveBackward() and dot(). moveForward(50); dot(10); moveBackward(100); dot(10); moveForward(50);
Example: Parallel Park the Turtle Use canvas drawing and moveBackward() to parallel park.
// Use canvas drawing and moveBackward() to parallel park. speed(10); createCanvas("id", 320, 480); setFillColor("yellow"); rect(180, 100, 60, 100); setFillColor("red"); rect(180, 300, 60, 100); show(); moveForward(75); moveBackward(50); turnLeft(45); moveBackward(75); turnRight(45); moveForward(); |
moveBackward(pixels);
Name | Type | Required? | Description |
---|---|---|---|
pixels | number | No | The number of pixels to move the turtle backward from its current direction. If not provided, the turtle will move forward 25 pixels |
No return value. Moves 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