xxxxxxxxxx
31
let cols; let rows; let size = 100;
let d = size/2;
let blocks = [];
function setup() {
createCanvas(400, 400);
cols = width/size;
rows = height/size;
for (let i=0; i<cols; i++) {
blocks[i] = [];
for (let j=0; j<rows; j++) {
if (i%2 == 0) {
blocks[i][j] = new Block(i*size, j*size, 0);
} else {
blocks[i][j] = new Block(i*size, j*size, 0);
}
}
}
}
function draw() {
background(0);
for (let i=0; i<cols; i++) {
for (let j=0; j<rows; j++) {
blocks[i][j].display();
}
}
}