Skip to content
Snippets Groups Projects
Commit 6b8da139 authored by De Brettes Thomas's avatar De Brettes Thomas
Browse files

échiquier inversé car Adam m'avait tout enlevé

parent 7fd45117
Branches
No related tags found
No related merge requests found
...@@ -111,6 +111,10 @@ socket.on('start game', (players) => { ...@@ -111,6 +111,10 @@ socket.on('start game', (players) => {
console.log(players, "Le jeu commence"); console.log(players, "Le jeu commence");
startGame(players); startGame(players);
console.log(player.isBlackPlayer) console.log(player.isBlackPlayer)
if (player.isBlackPlayer) {
document.getElementById('chessboard').classList.add('black-perspective');
console.log("échiquier inversé")
}
}); });
...@@ -249,6 +253,19 @@ function drawPieces() { ...@@ -249,6 +253,19 @@ function drawPieces() {
if (piece !== "") { if (piece !== "") {
let img = new Image(); let img = new Image();
img.src = "chess_pieces/" + pieceImages[piece]; img.src = "chess_pieces/" + pieceImages[piece];
if (player.isBlackPlayer){
img.onload = function () {
ctx.save();
ctx.translate((col) * size, (row) * size);
ctx.rotate(Math.PI);
ctx.drawImage(img, -size, -size, size, size);
ctx.restore();
};
img.onerror = function (e) {
console.log("Erreur de chargement de l'image : ", img.src); // En cas d'erreur de chargement
};
}
else{
img.onload = function () { img.onload = function () {
ctx.drawImage(img, col * size, row * size, size, size); ctx.drawImage(img, col * size, row * size, size, size);
}; };
...@@ -259,6 +276,7 @@ function drawPieces() { ...@@ -259,6 +276,7 @@ function drawPieces() {
} }
} }
} }
}
// Fonction principale pour dessiner l'échiquier // Fonction principale pour dessiner l'échiquier
function draw() { function draw() {
...@@ -447,6 +465,7 @@ function highlightMoves(tour,piece, row, col) { ...@@ -447,6 +465,7 @@ function highlightMoves(tour,piece, row, col) {
{ dr: 1, dc: 1 } // Diagonale bas-droite { dr: 1, dc: 1 } // Diagonale bas-droite
]; ];
for (let { dr, dc } of directions) { for (let { dr, dc } of directions) {
let newRow = row + dr; let newRow = row + dr;
let newCol = col + dc; let newCol = col + dc;
...@@ -458,6 +477,9 @@ function highlightMoves(tour,piece, row, col) { ...@@ -458,6 +477,9 @@ function highlightMoves(tour,piece, row, col) {
} }
} }
} }
if (row==7) {
if (board[row][col]){}
}
} }
if (piece.toLowerCase() === "c") { if (piece.toLowerCase() === "c") {
let movesL = [ let movesL = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment