Playing chess at the speed of light
Log in to post a comment.
Canvas.setpenopacity(1); let alternating = 0; //min=0, max=1, step=1 let squaresPerRotation = 20; //min=4, max=22, step=2 let offsetPerRotation = .1; //min=0, max=1, step=.1 const turtle = new Turtle(); turtle.setheading(90); squaresPerRotation += (squaresPerRotation % 2 == 1? 1: 0); //penstatus = 0 = pen is down; //penstatus = 1 = pen is up; var penstatus = 0; turtle.pendown(); function togglePen() { penstatus == 0? turtle.penup(): turtle.pendown(); penstatus = (penstatus + 1) % 2; } var r = 0; var alternate = 1 // The walk function will be called until it returns false. function walk(i) { var toggle = false; if(penstatus == 0) { toggle = true; togglePen(); } turtle.circle(i / 8, alternate * offsetPerRotation) if(toggle) { togglePen(); } if((i / 8) > r) { togglePen(); r = (i / squaresPerRotation) * Math.PI; if(alternating) { alternate *= -1; } } for(var j = 0; j < squaresPerRotation; j++) { turtle.circle(i / 8, 360/squaresPerRotation) togglePen(); } turtle.left(90); turtle.forward(1 / 8); turtle.right(90); return i < 1200; }