Git Product home page Git Product logo

pxt-microturtle's Introduction

micro turtle Build Status

A LOGO-like turtle library for the micro:bit in MakeCode.

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.

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.

turtle.back(1)

turn left #turtle-turnleft

Turns the turtle in a clockwise fashion by 90 degrees.

turtle.turnLeft()

turn right #turtle-turnright

Turns the turtle in a counter-clockwise fashion by 90 degrees.

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
turtle.pen(TurtlePenMode.Down)

set position #turtle-setposition

Moves the turtle to a particular location

turtle.setPosition(1,1)

home #turtle-home

Moves the turtle to the center of the screen, pointing up.

turtle.home()

set speed #turtle-setspeed

Determines how many steps per second a trutle may take.

turtle.setSpeed(50)

License

MIT

Supported targets

  • for PXT/microbit
  • for PXT/calliope

(The metadata above is needed for package search.)

pxt-microturtle's People

Contributors

microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar pelikhan avatar srietkerk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pxt-microturtle's Issues

Pen down un-clears the screen

Was just trying out this cool extension, very nice! One issue I'm having is that if I try to clear the screen after drawing with the pen down, as soon as the pen goes down again the clear function is essentially un-done.
Is there some other way to clear the screen I should use?

You can replicate it with this code:

input.onButtonPressed(Button.A, function () {
    turtle.setSpeed(25)
    turtle.pen(TurtlePenMode.Down)
    turtle.setPosition(0, 4)
    for (let index = 0; index <= 3; index++) {
        for (let index2 = 0; index2 < 3; index2++) {
            turtle.forward(4 - index)
            turtle.turnRight()
        }
        turtle.forward(3 - index)
        turtle.turnRight()
    }
})
input.onButtonPressed(Button.B, function () {
    basic.clearScreen()
    basic.pause(1000)
    turtle.pen(TurtlePenMode.Down)
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.