const guide = [2,3,4,5,6,4,3,2];
createCanvas(windowWidth, windowHeight);
offset = createVector(windowWidth/2 - 4*scl, windowHeight/2 - 4*scl);
for (var i = 1; i <= 8; i++) {
rect(offset.x, offset.y, offset.x + i*scl, offset.y + i*scl);
rect(offset.x + 8*scl, offset.y + 8*scl, offset.x + (8-i)*scl, offset.y + (8-i)*scl);
plateau.draw(scl, offset);
for (var i = 0; i < 8; i++) {
this.mat.push([0,0,0,0,0,0,0,0]);
this.mat[0] = initPieces(0);
this.mat[1] = initPions(0);
this.mat[6] = initPions(1);
this.mat[7] = initPieces(1);
for (var x = 0; x < 8; x++) {
for (var y = 0; y < 8; y++) {
if (this.mat[y][x] != 0) {
this.mat[y][x].draw(offset.x + scl*x, offset.y + scl*y, scl);
constructor(type, cote) {
ellipse(x + scl/2, y + scl/2, scl*0.6, scl*0.6);
rect(x + scl/2, y + scl/2, scl*0.6, scl*0.6);
triangle(x+0.3*scl, y+0.2*scl, x+0.7*scl, y+0.5*scl, x+0.3*scl, y+0.5*scl);
triangle(x+0.3*scl, y+0.2*scl, x+0.7*scl, y+0.8*scl, x+0.3*scl, y+0.8*scl);
triangle(x+0.2*scl, y+0.8*scl, x+0.5*scl, y+0.2*scl, x+0.8*scl, y+0.8*scl);
triangle(x+0.2*scl, y+0.8*scl, x+0.2*scl, y+0.3*scl, x+0.8*scl, y+0.8*scl);
triangle(x+0.2*scl, y+0.8*scl, x+0.8*scl, y+0.3*scl, x+0.8*scl, y+0.8*scl);
triangle(x+0.2*scl, y+0.8*scl, x+0.5*scl, y+0.2*scl, x+0.8*scl, y+0.8*scl);
rect(x+0.2*scl, y+0.6*scl, x+0.8*scl, y+0.8*scl);
arc(x+0.35*scl, y+0.6*scl, 0.3*scl, 0.4*scl, PI, 0);
arc(x+0.65*scl, y+0.6*scl, 0.3*scl, 0.4*scl, PI, 0);
line(x+0.5*scl, y+0.7*scl, x+0.5*scl, y+0.2*scl);
line(x+0.4*scl, y+0.3*scl, x+0.6*scl, y+0.3*scl);
getProjections(x, y, cote) {
function initPieces(cote) {
for (var i = 0; i < 8; i++) {
arr[i] = new Piece(guide[i], cote);
function initPions(cote) {
var pion = new Piece(1, cote);
for (var i = 0; i < 8; i++) {