https://github.com/microsoft/pxt-microturtle
A LOGO turtle library for micro:bit in MakeCode
https://github.com/microsoft/pxt-microturtle
micro microbit
Last synced: 5 days ago
JSON representation
A LOGO turtle library for micro:bit in MakeCode
- Host: GitHub
- URL: https://github.com/microsoft/pxt-microturtle
- Owner: microsoft
- License: mit
- Created: 2017-12-08T06:21:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-09T23:32:43.000Z (over 1 year ago)
- Last Synced: 2026-02-14T09:30:35.114Z (13 days ago)
- Topics: micro, microbit
- Language: TypeScript
- Homepage: https://makecode.microbit.org/pkg/microsoft/pxt-microturtle
- Size: 70.3 KB
- Stars: 5
- Watchers: 5
- Forks: 18
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# micro turtle [](https://travis-ci.org/Microsoft/pxt-microturtle)
A LOGO-like turtle library for the micro:bit in MakeCode.
```blocks
turtle.setPosition(0, 0)
turtle.setSpeed(45)
basic.forever(() => {
turtle.forward(4)
turtle.turnLeft()
})
```
The turtle is a single pixel moving on the micro:bit screen.
It starts in the center at ``2,2``, pointing up.
## Reference
### forward #turtle-forward
Moves the turtle forward by the given amount of steps. If the turtle goes out of the screen, it wraps around.
```sig
turtle.forward(1)
```
### back #turtle-back
Moves the turtle backward by the given amount of steps. If the turtle goes out of the screen, it wraps around.
```sig
turtle.back(1)
```
## turn left #turtle-turnleft
Turns the turtle in a clockwise fashion by 90 degrees.
```sig
turtle.turnLeft()
```
## turn right #turtle-turnright
Turns the turtle in a counter-clockwise fashion by 90 degrees.
```sig
turtle.turnRight()
```
## pen #turtle-pen
Sets the drawing mode of the turtle.
* ``up``, the turtle leaves no trail (this is the default)
* ``down``, the turtle paints the LEDs
```sig
turtle.pen(TurtlePenMode.Down)
```
## set position #turtle-setposition
Moves the turtle to a particular location
```sig
turtle.setPosition(1,1)
```
## home #turtle-home
Moves the turtle to the center of the screen, pointing up.
```sig
turtle.home()
```
## set speed #turtle-setspeed
Determines how many steps per second a trutle may take.
```sig
turtle.setSpeed(50)
```
## License
MIT
## Supported targets
* for PXT/microbit
* for PXT/calliope
(The metadata above is needed for package search.)