Category: Turtle
Moves the turtle forward a given number of pixels in the current direction.
moveForward() is the easiest way to move the turtle in a straight line in the direction it is facing. When used with turnLeft() and turnRight() you can navigate the turtle anywhere or draw any straight line pictures.
// Move forward 25 pixels (default) moveForward();
Example: Letter L Draw the letter L with moveForward() and turnLeft() only.
// Draw the letter L with moveForward() and turnLeft() only. turnLeft(); turnLeft(); moveForward(); moveForward(); turnLeft(); moveForward();
Example: Long Line Move forward 200 pixels.
// Move forward 200 pixels moveForward(200);
Example: Lemon Popsicle Draw a lemon popsicle by changing the pen color and width, and by specifing how many pixels the turtle should move in the direction forwards and backwards.
// Draw a lemon popsicle by changing the pen color and width // and by specifing how many pixels the turtle should move in the direction forwards and backwards. penColor("yellow"); penWidth(40); moveForward(100); penWidth(5); penColor("brown"); moveForward(-200); |
moveForward(pixels);
Name | Type | Required? | Description |
---|---|---|---|
pixels | number | No | The number of pixels to move the turtle forward in 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