xxxxxxxxxx
28
let tiles = [];
let cols; let rows; let size = 50;
let colors;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
colors = [color(255,240,1), color(255,1,1), color(1,1,253), color(249)];
cols = width/size;
rows = height/size;
for (let i=0; i<cols; i++) {
tiles[i] = [];
for (let j=0; j<rows; j++) {
tiles[i][j] = new Tile(i*size, j*size, floor(random(2)), colors[floor(random(4))]);
}
}
}
function draw() {
background(220);
for (let i=0; i<cols; i++) {
for (let j=0; j<rows; j++) {
tiles[i][j].display();
}
}
}