-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·232 lines (222 loc) · 9.08 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html>
<head>
<title>2D Chess Game</title>
<link rel="stylesheet" type="text/css" href="./assets/chess.css">
</head>
<body>
<h1>2D Chess Game</h1>
<div id="endscene">
<p class="winning-sign">white wins</p>
<div class="overlay">
</div>
</div>
<br>
<div style="width:600px;margin:auto;position:relative;">
<div id="board">
<div id="final" class="odd">
<div id="81" class="square" data-square="8-a">
<img class="piece rook" id="blackRook1" src="./assets/img/blackRook.png">
</div>
<div id="82" class="square" data-square="8-b">
<img class="piece knight" id="blackKnight1" src="./assets/img/blackKnight.png">
</div>
<div id="83" class="square" data-square="8-c">
<img class="piece bishop" id="blackBishop1" data-color="black" src="./assets/img/blackBishop.png">
</div>
<div id="84" class="square" data-square="8-d">
<img class="piece bking" id="blackQueen" data-color="black" src="./assets/img/blackQueen.png">
</div>
<div id="85" class="square" data-square="8-e">
<img class="piece bking" id="blackKing" data-color="black" src="./assets/img/blackKing.png">
</div>
<div id="86" class="square" data-square="8-f">
<img class="piece bishop" id="blackBishop2" data-color="black" src="./assets/img/blackBishop.png">
</div>
<div id="87" class="square" data-square="8-g">
<img class="piece bking" id="blackKnight2" data-color="black" src="./assets/img/blackKnight.png">
</div>
<div id="88" class="square" data-square="8-h">
<img class="piece rook" id="blackRook2" src="./assets/img/blackRook.png">
</div>
</div>
<div class="even">
<div id="71" class="square" data-square="7-a">
<img class="piece pawn" id="blackPawn1" src="./assets/img/blackPawn.png">
</div>
<div id="72" class="square" data-square="7-b">
<img class="piece pawn" id="blackPawn2" src="./assets/img/blackPawn.png">
</div>
<div id="73" class="square" data-square="7-c">
<img class="piece pawn" id="blackPawn3" src="./assets/img/blackPawn.png">
</div>
<div id="74" class="square" data-square="7-d">
<img class="piece pawn" id="blackPawn4" src="./assets/img/blackPawn.png">
</div>
<div id="75" class="square" data-square="7-e">
<img class="piece pawn" id="blackPawn5" src="./assets/img/blackPawn.png">
</div>
<div id="76" class="square" data-square="7-f">
<img class="piece pawn" id="blackPawn6" src="./assets/img/blackPawn.png">
</div>
<div id="77" class="square" data-square="7-g">
<img class="piece pawn" id="blackPawn7" src="./assets/img/blackPawn.png">
</div>
<div id="78" class="square" data-square="7-h">
<img class="piece pawn" id="blackPawn8" src="./assets/img/blackPawn.png">
</div>
</div>
<div class="odd">
<div id="61" class="square" data-square="6-a"></div>
<div id="62" class="square" data-square="6-b"></div>
<div id="63" class="square" data-square="6-c"></div>
<div id="64" class="square" data-square="6-d"></div>
<div id="65" class="square" data-square="6-e"></div>
<div id="66" class="square" data-square="6-f"></div>
<div id="67" class="square" data-square="6-g"></div>
<div id="68" class="square" data-square="6-h"></div>
</div>
<div class="even">
<div id="51" class="square" data-square="5-a"></div>
<div id="52" class="square" data-square="5-b"></div>
<div id="53" class="square" data-square="5-c"></div>
<div id="54" class="square" data-square="5-d"></div>
<div id="55" class="square" data-square="5-e"></div>
<div id="56" class="square" data-square="5-f"></div>
<div id="57" class="square" data-square="5-g"></div>
<div id="58" class="square" data-square="5-h"></div>
</div>
<div class="odd">
<div id="41" class="square" data-square="4-a"></div>
<div id="42" class="square" data-square="4-b"></div>
<div id="43" class="square" data-square="4-c"></div>
<div id="44" class="square" data-square="4-d"></div>
<div id="45" class="square" data-square="4-e"></div>
<div id="46" class="square" data-square="4-f"></div>
<div id="47" class="square" data-square="4-g"></div>
<div id="48" class="square" data-square="4-h"></div>
</div>
<div class="even">
<div id="31" class="square" data-square="3-a"></div>
<div id="32" class="square" data-square="3-b"></div>
<div id="33" class="square" data-square="3-c"></div>
<div id="34" class="square" data-square="3-d"></div>
<div id="35" class="square" data-square="3-e"></div>
<div id="36" class="square" data-square="3-f"></div>
<div id="37" class="square" data-square="3-g"></div>
<div id="38" class="square" data-square="3-h"></div>
</div>
<div class="odd">
<div class="square white" id="21" data-square="2-a">
<img class="piece pawn" id="whitePawn1" src="./assets/img/whitePawn.png">
</div>
<div class="square white" id="22" data-square="2-b">
<img class="piece pawn" id="whitePawn2" src="./assets/img/whitePawn.png">
</div>
<div class="square white" id="23" data-square="2-c">
<img class="piece pawn" id="whitePawn3" src="./assets/img/whitePawn.png">
</div>
<div class="square white" id="24" data-square="2-d">
<img class="piece pawn" id="whitePawn4" src="./assets/img/whitePawn.png">
</div>
<div class="square white" id="25" class="square" data-square="2-e">
<img class="piece pawn" id="whitePawn5" src="./assets/img/whitePawn.png">
</div>
<div class="square white" id="26" data-square="2-f">
<img class="piece pawn" id="whitePawn6" src="./assets/img/whitePawn.png">
</div>
<div class="square white" id="27" data-square="2-g">
<img class="piece pawn" id="whitePawn7" src="./assets/img/whitePawn.png">
</div>
<div class="square white" id="28" data-square="2-h">
<img class="piece pawn" id="whitePawn8" src="./assets/img/whitePawn.png">
</div>
</div>
<div class="even">
<div id="11" class="square white" data-square="1-a">
<img class="piece rook" id="whiteRook1" src="./assets/img/whiteRook.png">
</div>
<div id="12" class="square white" data-square="1-b">
<img class="piece knight" id="whiteKnight1" src="./assets/img/whiteKnight.png">
</div>
<div id="13" class="square white" data-square="1-c">
<img class="piece bishop" id="whiteBishop1" data-color="white" src="./assets/img/whiteBishop.png">
</div>
<div id="14" class="square white" data-square="1-d">
<img class="piece queen" id="whiteQueen" src="./assets/img/whiteQueen.png">
</div>
<div id="15" class="square white" data-square="1-e">
<img class="piece wking" src="./assets/img/whiteKing.png" class="white" id="whiteKing">
</div>
<div id="16" class="square white" data-square="1-f">
<img class="piece knight" id="whiteBishop2" src="./assets/img/whiteBishop.png">
</div>
<div id="17" class="square white" data-square="1-g">
<img class="piece knight" id="whiteKnight2" src="./assets/img/whiteKnight.png">
</div>
<div id="18" class="square white" data-square="1-h">
<img class="piece rook" id="whiteRook2" src="./assets/img/whiteRook.png">
</div>
</div>
</div>
<div id="sematary">
<div id="whiteSematary">
<div class="pawn"></div>
<div class="knight"></div>
<div class="bishop"></div>
<div class="rook"></div>
<div class="queen"></div>
</div>
<div id="blackSematary">
<div class="pawn"></div>
<div class="knight"></div>
<div class="bishop"></div>
<div class="rook"></div>
<div class="queen"></div>
</div>
</div>
<div style="margin-top: 50px;">
<button class="flip-board" onclick="boardAnimate()">Flip Board</button>
<p id="turn" class="turn-text"> White's Turn</p>
</div>
<hr style="max-width: 50vw; margin-top: 1vw;">
<div style="font-size:1.1rem; display: flex; align-items: center; justify-content: center; font-weight: 700;">
Made with <img height="0.15rem" style="margin: 0.15rem; height: 2rem; width: 2rem;" src="./assets/img/heart.png">by
<a style="text-decoration: none; color: #15ae66; margin-left: 0.25rem;"
target="_blank"
href="https://davymaish.github.io">David Maina
</a>
</div>
</div>
<script type="text/javascript" src="./src/Piece.js"></script>
<script type="text/javascript" src="./src/pieces/King.js"></script>
<script type="text/javascript" src="./src/pieces/Queen.js"></script>
<script type="text/javascript" src="./src/pieces/Rook.js"></script>
<script type="text/javascript" src="./src/pieces/Bishop.js"></script>
<script type="text/javascript" src="./src/pieces/Knight.js"></script>
<script type="text/javascript" src="./src/pieces/Pawn.js"></script>
<script type="text/javascript" src="./src/Game.js"></script>
<script type="text/javascript">
function boardAnimate(){
const board = document.getElementById('board');
const elements = board.getElementsByClassName('piece');
if (board.classList.contains('animate')) {
board.classList.remove('animate');
board.classList.add('animate-backward');
for (element of elements) {
element.classList.remove('forward');
element.classList.add('backward');
}
}
else{
board.classList.remove('animate-backward');
board.classList.add('animate');
for (element of elements) {
element.classList.remove('backward');
element.classList.add('forward');
}
}
}
</script>
</body>
</html>