Category: Turtle
Sets the speed for the app's execution, which includes the turtle's speed.
Slowing down the speed of the turtle while drawing allows us to see the execution of each command more easily.
// Draw a line slowly. speed(1); moveForward();
Example: Different Speeds Draw a square with the turtle moving at increasingly faster speeds (10, 20, 30, 40, 50, 60, 70, 80, 90, 100).
// Draw a square with the turtle moving at increasingly faster speeds // (10, 20, 30, 40, 50, 60, 70, 80, 90, 100). textLabel("speed", "speed: 10"); for (var i = 1; i <= 10; i++) { for (var j = 0; j < 4; j++) { setText("speed", "speed: " + i * 10); speed(i*10); moveForward(100); turnRight(90); } } |
speed(value);
Name | Type | Required? | Description |
---|---|---|---|
value | number | Yes | The speed of the app's execution in the range of (0-100) |
No return value. Alters execution speed 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