-
Notifications
You must be signed in to change notification settings - Fork 0
/
5zq.html
40 lines (40 loc) · 1.7 KB
/
5zq.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
<html>
<span id="chess"></span>
<button onclick="back()">悔棋</button>
<script>
var board=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
var step=[]
gengxin()
function gengxin(){
document.getElementById("chess").innerHTML=''
for(var i=0;i<15;i++){
for(var j=0;j<15;j++){
if(board[i][j]==0){
document.getElementById("chess").innerHTML+='<img src="empty.PNG" width="57" height="57">'
}
else if(board[i][j]==1){
document.getElementById("chess").innerHTML+='<img src="black.PNG" width="57" height="57">'
}
else if(board[i][j]==2){
document.getElementById("chess").innerHTML+='<img src="white.PNG" width="57" height="57">'
}
}
document.getElementById("chess").innerHTML+='<br>'
}
}
function back(){
board[step[step.length-1][0]][step[step.length-1][1]]=0
step.pop()
gengxin()
}
document.addEventListener("click", function (e) {
if(board[Math.floor(e.clientY/57)][Math.floor(e.clientX/57)]==0){
board[Math.floor(e.clientY/57)][Math.floor(e.clientX/57)]=step.length%2+1
step.push([Math.floor(e.clientY/57),Math.floor(e.clientX/57)])
gengxin()
}
})
</script>
</html>