cutechicken commited on
Commit
9f02839
Β·
verified Β·
1 Parent(s): 642e14e

Update index.html

Browse files
Files changed (1) hide show
  1. 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
- function startCountdown() {
139
- isCountingDown = true;
140
- countdownTime = 3;
141
- countdownEl.style.display = 'block';
142
- countdownEl.textContent = countdownTime;
143
- const countInterval = setInterval(() => {
144
- countdownTime--;
145
- if(countdownTime <= 0) {
146
- clearInterval(countInterval);
147
- countdownEl.style.display = 'none';
148
- isCountingDown = false;
149
- }
150
- countdownEl.textContent = countdownTime > 0 ? countdownTime : 'GO!';
151
- }, 1000);
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
- Promise.all([
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;