Skip to content

Instantly share code, notes, and snippets.

@gonzam88
Last active October 31, 2018 23:04
Show Gist options
  • Save gonzam88/3ee789df2ec255ef7e1c0a61fb9da2b4 to your computer and use it in GitHub Desktop.
Save gonzam88/3ee789df2ec255ef7e1c0a61fb9da2b4 to your computer and use it in GitHub Desktop.
mini maze for Melt - Polarcontroller
var xoff = melt.PenPosition().x, yoff = melt.PenPosition().y;
var grid = 3;
var alto = 330, ancho = 490;
for(let i=0; i<ancho/grid; i++){
for(let j=0; j<alto/grid; j++){
PickOne()? LtR(i*grid, j*grid) : RtL(i*grid, j*grid);
}
}
function PickOne(){
return Math.floor(Math.random()*2) ? true:false;
}
function RtL(x,y){
melt.line(x+xoff, y+yoff, x+xoff+grid, y+yoff+grid);
}
function LtR(x,y){
melt.line(x+xoff+grid, y+yoff, x+xoff, y+yoff+grid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment