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