Invaders

WE COME IN PEACE

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

// Global code will be evaluated once.
const turtle = new Turtle();

// The walk function will be called until it returns false.
function walk(i) {
    const x = i % 16;
    const y = i / 16 >> 0;
    for (let i = 0; i < 8; i++) {
        let bits = Math.random().toString(2).substr(2,4).split("");
        bits = bits.concat(bits.slice().reverse());
        bits.forEach((n, j) => {
            if (n === "1") {
                turtle.up();
                turtle.goto(
                -94 + x * 12 + j,
                -94 + y * 12 + i
                );
                turtle.down();
                turtle.circle(0.3);
                turtle.circle(0.2);
                turtle.circle(0.1);
            }
        });
    }
    return i < 16 * 16 - 1;
}