xxxxxxxxxx
43
let tiles = [];
let rez = 60;
let pawns = [];
function setup() {
createCanvas(rez * 8, rez * 8);
const rows = 8;
const cols = 8;
let x = 0;
let y = 0;
for(let i = 0; i < rows * cols; i++) {
tiles[i] = new Tile(x, y, i, rez);
x += rez;
if(x == width) {
x = 0;
y += rez;
}
}
for(let i = 0; i < 8; i++) {
pawns[i] = new Piece(tiles[i + 48], 0, 255, 0);
}
}
function draw() {
background(0);
for(let tile of tiles) {
tile.show();
}
for(let pawn of pawns) {
pawn.show();
if(pawn.clicked(mouseX, mouseY)) {
console.log("f")
} else {
}
}
}