-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.html
124 lines (103 loc) · 3.6 KB
/
menu.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
<!DOCTYPE html>
<html>
<head>
<script src="/assets/js/babylon/babylon.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>Babylon.js sample code</title>
<link rel="stylesheet" href="./assets/css/menu.css">
</head>
<body>
<audio id="bgm" src="/assets/sounds/bgm.mp3"></audio>
<audio id="click" src="/assets/sounds/click.wav" autoplay="false"></audio>
<div id="bodyImg"></div>
<div class="buttonDiv">
<button class="btn-3d" id="decoyButton">
Start Game
</button>
<br />
<button class="btn-3d" id="instructButton">
Instructions
</button>
<br />
<button class="btn-3d" id="BGMSound">
Sound : ON
</button>
</div>
<div class="custom-component">
<span class="custom-close-button">×</span>
<h2>How to play</h2>
<img src="/assets/img/instruction.jpeg" class="screenshot" />
<p class="iText">Tap on the angry cubes to kill them</p>
<p class="iText">Kill them before they collide on you and damage your health</p>
<p class="iText">Maximise the kills</p>
</div>
</body>
<script>
// Get the button and component elements
const button = document.querySelector('#instructButton');
const component = document.querySelector('.custom-component');
const closeButton = document.querySelector('.custom-close-button');
// Add a click event listener to the button
button.addEventListener('click', () => {
// Show the component
component.style.display = 'block';
});
// Add a click event listener to the close button
closeButton.addEventListener('click', () => {
// Hide the component
component.style.display = 'none';
});
window.onload = function () {
// alert("Welcome Back")
let audio = document.getElementById('bgm');
audio.play().catch(function (error) {
console.error('Autoplay failed:', error);
});
}
var AUDIO_STATE = 1
window.addEventListener("click", () => {
if (AUDIO_STATE) {
let audio = document.getElementById('bgm');
audio.play().catch(function (error) {
console.error('Autoplay failed:', error);
});
}
})
function animateButton() {
var button = document.querySelector("button");
button.style.transform = "translateY(0)";
button.style.boxShadow = "none";
setTimeout(function () {
button.style.transform = "translateY(2px)";
button.style.boxShadow = "0 2px 2px rgba(0,0,0,0.4)";
}, 100);
}
var bgmAudio = document.getElementById("bgm");
var clickAudio = document.getElementById("click");
document.querySelector("#decoyButton").onclick = () => {
var link = document.createElement('a');
link.href = '/game';
clickAudio.play()
animateButton()
link.click()
}
document.querySelector("#instructButton").onclick = () => {
clickAudio.play()
animateButton()
}
document.querySelector("#BGMSound").onclick = () => {
if (AUDIO_STATE == 1) {
bgmAudio.pause();
AUDIO_STATE = 0;
document.querySelector("#BGMSound").innerHTML = "SOUND : OFF"
} else {
AUDIO_STATE = 1;
bgmAudio.play();
document.querySelector("#BGMSound").innerHTML = "SOUND : ON"
}
clickAudio.play()
animateButton()
}
</script>
</html>