-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
52 lines (49 loc) · 1.71 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>赛车小游戏</title>
<script>
!function (a) { var b, c; /Android (\d+\.\d+)/.test(navigator.userAgent) ? (b = parseFloat(RegExp.$1), b > 2.3 ? (c = parseInt(window.screen.width) / a, document.write('<meta name="viewport" content="width=' + a + ",minimum-scale=" + c + ",maximum-scale=" + c + ', target-densitydpi=device-dpi">')) : document.write('<meta name="viewport" content="width=' + a + ',target-densitydpi=device-dpi">')) : document.write('<meta name="viewport" content="width=' + a + ',user-scalable=no,target-densitydpi=device-dpi,minimal-ui,viewport-fit=cover">') }(750);
</script>
<link rel="stylesheet" href="index.css">
</head>
<body οncοntextmenu="return false">
<div id="Jgame">
<div class="score-wrap">
分数: <span id="Jscore">0</span>
</div>
</div>
<div class="btn-wrap">
<div id="Jstart" class="btn-start">开始</div>
<div id="Jreplay" class="btn-start">重玩</div>
</div>
<script src="index.js"></script>
<script>
; (() => {
document.addEventListener('DOMContentLoaded', (e) => {
Game.init({
ele: '#Jgame',
type:1, // 0:蓝色车,1:红色车
speed: 20,
speedPadding: 2,
scoreUpdate(score) {
console.log('分数:',score);
Jscore.innerHTML = score
},
gameOver() {
console.log('游戏结束');
}
})
Jstart.addEventListener('click', (e) => {
Game.play()
}, false)
Jreplay.addEventListener('click', (e) => {
Jscore.innerHTML = '0'
Game.replay()
}, false)
}, false)
})()
</script>
</body>
</html>