xxxxxxxxxx
45
var rows = 4;
var cols = 4;
var startx = 0;
var starty = 0;
var space = 95;
function setup() {
createCanvas(400, 400);
}
function draw(){
background(222);
//the important nested forloop
for (row = 0 ; row< rows; row ++ ){
for (col = 0; col < cols; col ++){
scotty (startx + (space*col), starty + (space*row));
}
}
function scotty(x, y) {
noStroke();
fill("red");
beginShape();
vertex(x+20,y+50);
vertex(x+60,y+50);
vertex(x+70,y+110);
vertex(x+20,y+70);
endShape();
fill(0);
rect(x+30,y+20,50,30)
triangle(x+80,y+20, x+80,y+70,x+50,y+20);
triangle (x+30,y+20, x+30,y+0, x+50,y+20);
fill(255);
circle(x+50,y+30,5);
}
}