Random Ticks in Lanes

Random Ticks in Lanes

Log in to post a comment.

// Forked from "Squiral" by Posthuman1000
// https://turtletoy.net/turtle/c7de6191aa

// 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();
const listOfRandos = [0,0,0,0,0,0,0,0,0,0,0];
var rowHeight = 5
var tickAngle = 77.5 // <80 slope right, >80 slope left 
turtle.penup();
turtle.goto(-80,-80);
turtle.pendown();

function outline(i) {
    

     return i < 4;
}


// The walk function will be called until it returns false.
function walk() {
    
    for (let i = 0; i < 4; i++) {
    turtle.forward(160);
    turtle.right(90);
    }
	
    do {
		
	for (let i = 0; i < listOfRandos.length; i++){
    listOfRandos[i] = getRandomInt(0, 160);
	}			
		
	for (let i = 0; i < listOfRandos.length; i++){
    turtle.goto(listOfRandos[i]-80,turtle.ycor());
    if (listOfRandos[i]-tickAngle > -80 && listOfRandos[i]-tickAngle < 80){
    turtle.goto(listOfRandos[i]-tickAngle,turtle.ycor()+rowHeight);
    turtle.goto(listOfRandos[i]-80,turtle.ycor()-rowHeight);
    }
	}
    turtle.goto(80,turtle.ycor());
    turtle.right(90);
    turtle.forward(rowHeight);
    turtle.right(90);
    //turtle.forward(turtle.xcor(), 160-turtle.ycor());
    turtle.goto(-80,turtle.ycor());
    //turtle.left(90);
    //turtle.forward(2);
    turtle.left(180);
    } while (turtle.ycor() < 79);
    

function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}
}