2017-12-08 23:56:39 +01:00
|
|
|
# Turtle Spiral
|
|
|
|
|
2017-12-11 04:12:08 +01:00
|
|
|
A turtle that spirals into the center of the display and back out again.
|
2017-12-08 23:56:39 +01:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
let index = 0
|
|
|
|
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#master
|
|
|
|
```
|