Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Echecs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Elarouti Adam
Echecs
Commits
6b8da139
Commit
6b8da139
authored
4 months ago
by
De Brettes Thomas
Browse files
Options
Downloads
Patches
Plain Diff
échiquier inversé car Adam m'avait tout enlevé
parent
7fd45117
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/index.js
+22
-0
22 additions, 0 deletions
htdocs/index.js
with
22 additions
and
0 deletions
htdocs/index.js
+
22
−
0
View file @
6b8da139
...
@@ -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
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment