Spaces:
Running
Running
Update index.html
Browse files- index.html +22 -15
index.html
CHANGED
@@ -109,6 +109,9 @@
|
|
109 |
const cannonSound = new Audio('firemn.ogg');
|
110 |
const machinegunSound = new Audio('firemg.ogg');
|
111 |
const enemyFireSound = new Audio('fireenemy.ogg');
|
|
|
|
|
|
|
112 |
enemyFireSound.volume = 0.5;
|
113 |
const weapons = {
|
114 |
cannon: {
|
@@ -135,21 +138,24 @@
|
|
135 |
health: 1000,
|
136 |
maxHealth: 1000
|
137 |
};
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
}
|
|
|
|
|
|
|
153 |
class Enemy {
|
154 |
constructor() {
|
155 |
this.x = Math.random() * canvas.width;
|
@@ -369,13 +375,14 @@
|
|
369 |
restartBtn.style.display = 'none';
|
370 |
initRound();
|
371 |
});
|
372 |
-
|
373 |
new Promise(resolve => backgroundImg.onload = resolve),
|
374 |
new Promise(resolve => playerImg.onload = resolve),
|
375 |
new Promise(resolve => enemyImg.onload = resolve)
|
376 |
]).then(() => {
|
377 |
initRound();
|
378 |
gameLoop();
|
|
|
379 |
});
|
380 |
window.addEventListener('resize', () => {
|
381 |
canvas.width = window.innerWidth;
|
|
|
109 |
const cannonSound = new Audio('firemn.ogg');
|
110 |
const machinegunSound = new Audio('firemg.ogg');
|
111 |
const enemyFireSound = new Audio('fireenemy.ogg');
|
112 |
+
const bgm = new Audio('BGM.ogg');
|
113 |
+
const countSound = new Audio('count.ogg');
|
114 |
+
bgm.loop = true;
|
115 |
enemyFireSound.volume = 0.5;
|
116 |
const weapons = {
|
117 |
cannon: {
|
|
|
138 |
health: 1000,
|
139 |
maxHealth: 1000
|
140 |
};
|
141 |
+
function startCountdown() {
|
142 |
+
isCountingDown = true;
|
143 |
+
countdownTime = 3;
|
144 |
+
countdownEl.style.display = 'block';
|
145 |
+
countdownEl.textContent = countdownTime;
|
146 |
+
bgm.pause(); // BGM μΌμμ μ§
|
147 |
+
countSound.play(); // μΉ΄μ΄νΈλ€μ΄ μ¬μ΄λ μ¬μ
|
148 |
+
const countInterval = setInterval(() => {
|
149 |
+
countdownTime--;
|
150 |
+
if(countdownTime <= 0) {
|
151 |
+
clearInterval(countInterval);
|
152 |
+
countdownEl.style.display = 'none';
|
153 |
+
isCountingDown = false;
|
154 |
+
bgm.play(); // BGM λ€μ μ¬μ
|
155 |
}
|
156 |
+
countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
|
157 |
+
}, 1000);
|
158 |
+
}
|
159 |
class Enemy {
|
160 |
constructor() {
|
161 |
this.x = Math.random() * canvas.width;
|
|
|
375 |
restartBtn.style.display = 'none';
|
376 |
initRound();
|
377 |
});
|
378 |
+
Promise.all([
|
379 |
new Promise(resolve => backgroundImg.onload = resolve),
|
380 |
new Promise(resolve => playerImg.onload = resolve),
|
381 |
new Promise(resolve => enemyImg.onload = resolve)
|
382 |
]).then(() => {
|
383 |
initRound();
|
384 |
gameLoop();
|
385 |
+
bgm.play(); // κ²μ μμμ BGM μ¬μ
|
386 |
});
|
387 |
window.addEventListener('resize', () => {
|
388 |
canvas.width = window.innerWidth;
|