xxxxxxxxxx
27
let rows = 0;
let cols = 0;
let blocks = [];
let w = 40;
let h = w;
function setup() {
createCanvas(600, 400);
rows = height / h;
cols = width / w;
for (let i = 0; i < cols; i++) {
blocks[i] = [];
for (let j = 0; j < rows; j++) {
blocks[i][j] = new Block(i * w, j * h, w, h);
}
}
}
function draw() {
background(0);
for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
blocks[i][j].show();
}
}
}