Obstructing the light with primitive, overly complex behaviors.
Log in to post a comment.
Canvas.setpenopacity(-0.05); const size = 200; let turtles = []; let nt, sync, iter = 0; Turtle.prototype.withinBounds = function() { return this.x() >= this.bounds[0] && this.y() >= this.bounds[1] && this.x() < this.bounds[2] && this.y() < this.bounds[3]; } Turtle.prototype.setBounds = function(...args) { this.bounds = [...args]; } const spawnTurtle = (x = 0, y = 0, angle = 15) => { const turtle = new Turtle(); turtle.penup(); turtle.goto(x, y); turtle.seth(angle); turtle.root = true; turtle.pendown(); turtle.health = 1000; return turtle; } function walk(i) { if (turtles.length) { turtles.map((turtle, idx) => { sync = Math.sin(0.25*iter+0.03*i+0.5*Math.cos(100+turtle.y()*(idx+1))*(idx+1)) turtle.angle = 30*sync; iter%2==0 ? turtle.left(turtle.angle) : turtle.right(turtle.angle); turtle.forward(0.5); if (turtle.root && Math.abs(turtle.angle) > 2) { nt = turtle.clone(); nt.angle = turtle.angle*10*sync; nt.setBounds( Math.max(-100, turtle.x()-turtle.health), Math.max(-100, turtle.y()-turtle.health), Math.min(100, turtle.x()+turtle.health), Math.min(100, turtle.y()+turtle.health) ); turtles.push(nt); } turtle.health -= 0.02; }); turtles = turtles.filter(turtle => { if (!turtle.withinBounds() || (Math.abs(turtle.x()) < 10 && (turtle.y() > -55 && turtle.y() < 55))) { iter++; return false; } return true; }); } else { for (let n = 5; n > 0; n--) { nt = spawnTurtle(-50, -160+40*n, 360*Math.random()); nt.setBounds(-size/2, -size/2, size/2, size/2); turtles.push(nt); } } return i < 40000; }