cutechicken commited on
Commit
06b342a
Β·
verified Β·
1 Parent(s): 98abe6b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +37 -17
index.html CHANGED
@@ -242,6 +242,11 @@
242
  let bgm = new Audio('title.ogg');
243
  const countSound = new Audio('count.ogg');
244
  const deathSound = new Audio('death.ogg');
 
 
 
 
 
245
  bgm.loop = true;
246
  enemyFireSound.volume = 0.5;
247
 
@@ -956,7 +961,14 @@ function updateGame() {
956
 
957
  fireBullet();
958
  }
959
-
 
 
 
 
 
 
 
960
  // BF109 κ΄€λ ¨ μ½”λ“œ
961
  if (hasBF109 && !isCountingDown) {
962
  const now = Date.now();
@@ -1008,22 +1020,30 @@ function updateGame() {
1008
  bullet.y += Math.sin(bullet.angle) * bullet.speed;
1009
 
1010
  if(!bullet.isEnemy) {
1011
- enemies = enemies.filter(enemy => {
1012
- const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
1013
- if(dist < 30) {
1014
- let damage = currentWeapon === 'cannon' ? 250 : 50;
1015
- enemy.health -= damage;
1016
- if(enemy.health <= 0) {
1017
- spawnHealthItem(enemy.x, enemy.y);
1018
- gold += 100;
1019
- effects.push(new Effect(enemy.x, enemy.y, 1000, 'death'));
1020
- deathSound.cloneNode().play();
1021
- return false;
1022
- }
1023
- return true;
1024
- }
1025
- return true;
1026
- });
 
 
 
 
 
 
 
 
1027
  } else {
1028
  // 상점이 μ—΄λ €μžˆμ§€ μ•Šμ„ λ•Œλ§Œ ν”Œλ ˆμ΄μ–΄ 데미지 처리
1029
  if (!document.getElementById('shop').style.display ||
 
242
  let bgm = new Audio('title.ogg');
243
  const countSound = new Audio('count.ogg');
244
  const deathSound = new Audio('death.ogg');
245
+ let currentHitSound = null;
246
+ let currentReloadSound = null;
247
+ const hitSounds = Array.from({length: 6}, (_, i) => new Audio(`hit${i+1}.ogg`));
248
+ const reloadSounds = [new Audio('reload1.ogg'), new Audio('reload2.ogg')];
249
+ const escapeSound = new Audio('escape.ogg');
250
  bgm.loop = true;
251
  enemyFireSound.volume = 0.5;
252
 
 
961
 
962
  fireBullet();
963
  }
964
+ // ν…ŒμŠ€νŠΈμ€‘, μ•ˆλ˜λ©΄ μ‚­μ œ
965
+ if(player.health <= 0) {
966
+ gameOver = true;
967
+ restartBtn.style.display = 'block';
968
+ effects.push(new Effect(player.x, player.y, 1000, 'death'));
969
+ deathSound.cloneNode().play();
970
+ escapeSound.play(); // 사망 μ‹œ escape.ogg μž¬μƒ
971
+ }
972
  // BF109 κ΄€λ ¨ μ½”λ“œ
973
  if (hasBF109 && !isCountingDown) {
974
  const now = Date.now();
 
1020
  bullet.y += Math.sin(bullet.angle) * bullet.speed;
1021
 
1022
  if(!bullet.isEnemy) {
1023
+ enemies = enemies.filter(enemy => {
1024
+ const dist = Math.hypot(bullet.x - enemy.x, bullet.y - enemy.y);
1025
+ if(dist < 30) {
1026
+ let damage = currentWeapon === 'cannon' ? 250 : 50;
1027
+ enemy.health -= damage;
1028
+ if(enemy.health <= 0) {
1029
+ spawnHealthItem(enemy.x, enemy.y);
1030
+ gold += 100;
1031
+ effects.push(new Effect(enemy.x, enemy.y, 1000, 'death'));
1032
+ deathSound.cloneNode().play();
1033
+
1034
+ // 히트 μ‚¬μš΄λ“œ μž¬μƒ μΆ”κ°€
1035
+ if (!currentHitSound || currentHitSound.ended) {
1036
+ currentHitSound = hitSounds[Math.floor(Math.random() * hitSounds.length)];
1037
+ currentHitSound.volume = 1.0;
1038
+ currentHitSound.play();
1039
+ }
1040
+
1041
+ return false;
1042
+ }
1043
+ return true;
1044
+ }
1045
+ return true;
1046
+ });
1047
  } else {
1048
  // 상점이 μ—΄λ €μžˆμ§€ μ•Šμ„ λ•Œλ§Œ ν”Œλ ˆμ΄μ–΄ 데미지 처리
1049
  if (!document.getElementById('shop').style.display ||