2017-12-08 14:56:39 -08:00
|
|
|
# Turtle Spiral
|
|
|
|
|
2018-09-11 09:02:40 -07:00
|
|
|
## Setting up your project
|
|
|
|
|
2019-05-30 16:15:38 -07:00
|
|
|
This project uses the **microturtle** Extension. You'll need to add it to your project to make it work.
|
2018-09-11 09:02:40 -07:00
|
|
|
|
|
|
|
* 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
|
|
|
|
|
2017-12-10 19:12:08 -08:00
|
|
|
A turtle that spirals into the center of the display and back out again.
|
2017-12-08 14:56:39 -08:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
turtle.setPosition(0, 0)
|
|
|
|
turtle.turnRight()
|
|
|
|
basic.forever(() => {
|
2019-05-30 16:15:38 -07:00
|
|
|
for (let index = 0; index <= 4; index++) {
|
2017-12-08 14:56:39 -08:00
|
|
|
turtle.forward(4 - index)
|
|
|
|
turtle.turnRight()
|
|
|
|
}
|
2019-05-30 16:15:38 -07:00
|
|
|
for (let index = 0; index <= 4; index++) {
|
2017-12-08 14:56:39 -08:00
|
|
|
turtle.turnLeft()
|
|
|
|
turtle.back(index)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
```package
|
2018-10-15 15:32:09 -07:00
|
|
|
microturtle=github:Microsoft/pxt-microturtle#v0.0.9
|
2017-12-08 14:56:39 -08:00
|
|
|
```
|