pxt-calliope/docs/projects/turtle-spiral.md
Michał Moskal 71d98822ae
Support latest PXT with GC (#1798)
* Enable gc and basic compilation fixes

* Add missing GC stuff

* Set microbit-dal version

* Disable jacdac in servo

* UTF fixes

* TS build fixes

* Auto-generated files update

* We only seem to have that much

* Fix for new new compiler

* Account for uninitialized scheduler

* Intialize memory allocator

* bump references

* updated package

* Set image tag, requires https://github.com/Microsoft/pxt/pull/5262

* updated project summaries

* Fixing block tests
2019-02-21 15:41:32 -08:00

809 B

Turtle Spiral

Setting up your project

This project uses an 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.

let index = 0
turtle.setPosition(0, 0)
turtle.turnRight()
basic.forever(() => {
    for (index = 0; index <= 4; index++) {
        turtle.forward(4 - index)
        turtle.turnRight()
    }
    for (index = 0; index <= 4; index++) {
        turtle.turnLeft()
        turtle.back(index)
    }
})
microturtle=github:Microsoft/pxt-microturtle#v0.0.9