-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
54 lines (51 loc) · 1.14 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>俄罗斯方块</title>
</head>
<style>
body{
text-align: center;
}
#game{
border: 1px solid rgba(0, 0, 0, .2);
display: inline-block;
margin: auto;
font-size: 0;
}
#opts{
margin-bottom: 10px;
}
</style>
<body>
<div id="opts">
<button id="rePlayBtn">重新游戏</button>
<button id="pauseBtn">暂停游戏</button>
<button id="helpBtn">辅助线:<span id="helpLine">off</span></button>
</div>
<div id="game"></div>
</body>
</html>
<script src="./index.js"></script>
<script>
const game = new ELuoSiGame({
selector: '#game',
width: 150,
height: 230,
})
pauseBtn.onclick = () => {
game.pauseGame()
pauseBtn.innerText = game.pause ? '继续游戏' : '暂停游戏'
}
rePlayBtn.onclick = () => {
pauseBtn.innerText = '暂停游戏'
game.reStartGame()
}
helpBtn.onclick = () => {
game.toggleHelp()
helpLine.innerText = game.help ? 'on' : 'off'
}
</script>