pxt-calliope/docs/examples/turtle-spiral.md
2017-12-08 14:56:39 -08:00

449 B

Turtle Spiral

The turtle goes to the center back and forth.

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)
    }
})
microturtle=github:Microsoft/pxt-microturtle#master