-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (70 loc) · 2.22 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
<!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">
<link rel="stylesheet" href="style.css">
<title>web game</title>
</head>
<body>
<div id="game">
<div id="bluecar">
<p align="center"><img src="car3.png" class="enemy"></p>
</div>
<div id="racecar">
<p align="center"><img src="main.png" class="user"></p>
</div>
</div>
<!-- <div id="stop-btn">
<button id="stopgame" onclick="">stop</button>
</div> -->
<div id="result">
<h1>Game Over</h1>
<p id="score"></p>
<button id="btn" onclick="location.reload()">Restart</button>
</div>
<!-- <audio src="click.wav" id="clicksound"></audio> -->
<script src="script.js"></script>
</body>
<!-- game voice controle -->
<script src="//cdnjs.cloudflare.com/ajax/libs/annyang/2.6.1/annyang.min.js"></script>
<script>
if (annyang) {
// Let's define a command.
const commands = {
'right': () => {
// your code here
var raceCarLeft = parseInt(window.getComputedStyle(raceCar).getPropertyValue("left"))
if (raceCarLeft < 120) { raceCar.style.left = (raceCarLeft + 120) + "px" }
}
};
// Add our commands to annyang
annyang.addCommands(commands);
// Start listening.
annyang.start();
}
if (annyang) {
const commands = {
'left': () => {
var raceCarLeft = parseInt(window.getComputedStyle(raceCar).getPropertyValue("left"))
if (raceCarLeft > 0) { raceCar.style.left = (raceCarLeft - 120) + "px" }
}
};
// Add our commands to annyang
annyang.addCommands(commands);
// Start listening.
annyang.start();
}
if (annyang) {
// Let's define a command.
const commands = {
'stop': () => { alert('press ok to continue...!'); }
};
// Add our commands to annyang
annyang.addCommands(commands);
// Start listening.
annyang.start();
}
</script>
</html>