pxt-calliope/docs/projects/turtle-spiral.md
Joey Wunderlich 65a05bf2d5
Fix Turtle Spiral example decompilation (#2094)
* use local variables for indices

* s/an/the/
2019-05-30 16:15:38 -07:00

35 lines
804 B
Markdown

# Turtle Spiral
## Setting up your project
This project uses the **microturtle** Extension. You'll need to add it to your project to make it work.
* create a new project
* click on the gearwheel menu and click **Extensions**
* select the **microturtle** extension
After the project reloads, you should see the **turtle** category in the blocks.
## Code
A turtle that spirals into the center of the display and back out again.
```blocks
turtle.setPosition(0, 0)
turtle.turnRight()
basic.forever(() => {
for (let index = 0; index <= 4; index++) {
turtle.forward(4 - index)
turtle.turnRight()
}
for (let index = 0; index <= 4; index++) {
turtle.turnLeft()
turtle.back(index)
}
})
```
```package
microturtle=github:Microsoft/pxt-microturtle#v0.0.9
```