cutechicken commited on
Commit
d559dac
Β·
verified Β·
1 Parent(s): 3d2129f

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +70 -54
game.js CHANGED
@@ -2070,55 +2070,61 @@ class Game {
2070
  }
2071
 
2072
  checkCollisions() {
2073
- // ν”Œλ ˆμ΄μ–΄ νƒ„ν™˜ vs 적기 좩돌
2074
- for (let i = this.fighter.bullets.length - 1; i >= 0; i--) {
2075
- const bullet = this.fighter.bullets[i];
2076
-
2077
- for (let j = this.enemies.length - 1; j >= 0; j--) {
2078
- const enemy = this.enemies[j];
2079
- if (!enemy.mesh || !enemy.isLoaded) continue;
 
 
 
 
 
 
 
2080
 
2081
- const distance = bullet.position.distanceTo(enemy.position);
2082
- if (distance < 90) { // 60μ—μ„œ 90으둜 증가 (100% ν™•λŒ€)
2083
- // 히트 ν‘œμ‹œ μΆ”κ°€
2084
- this.showHitMarker(enemy.position);
2085
- // 피격 μ΄νŽ™νŠΈ μΆ”κ°€
2086
- this.createHitEffect(enemy.position);
2087
-
2088
- // νƒ„ν™˜ μ œκ±°λŠ” μ΄νŽ™νŠΈ 생성 후에
2089
- this.scene.remove(bullet);
2090
- this.fighter.bullets.splice(i, 1);
2091
 
2092
- if (enemy.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) { // 50 데미지
2093
- enemy.destroy();
2094
- this.enemies.splice(j, 1);
2095
- this.score += 100;
2096
- }
2097
- break;
2098
  }
 
2099
  }
2100
  }
2101
-
2102
- // 적 νƒ„ν™˜ vs ν”Œλ ˆμ΄μ–΄ 좩돌
2103
- this.enemies.forEach(enemy => {
2104
- for (let index = enemy.bullets.length - 1; index >= 0; index--) {
2105
- const bullet = enemy.bullets[index];
2106
- const distance = bullet.position.distanceTo(this.fighter.position);
2107
- if (distance < 100) { // 65μ—μ„œ 100으둜 증가 (100% ν™•λŒ€)
2108
- // ν”Œλ ˆμ΄μ–΄ 피격 μ΄νŽ™νŠΈ
2109
- this.createHitEffect(this.fighter.position);
2110
-
2111
- // νƒ„ν™˜ 제거
2112
- this.scene.remove(bullet);
2113
- enemy.bullets.splice(index, 1);
 
 
 
 
 
2114
 
2115
- if (this.fighter.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) { // 50 데미지
2116
- this.endGame(false);
2117
- }
2118
  }
2119
  }
2120
- });
2121
- }
 
2122
 
2123
  createHitEffect(position) {
2124
  // 피격 νŒŒν‹°ν΄ 효과 생성
@@ -2215,6 +2221,20 @@ class Game {
2215
  }
2216
 
2217
  createExplosionEffect(position) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2218
  // 메인 폭발 ν”Œλž˜μ‹œ
2219
  const explosionGeometry = new THREE.SphereGeometry(50, 16, 16);
2220
  const explosionMaterial = new THREE.MeshBasicMaterial({
@@ -2296,15 +2316,6 @@ class Game {
2296
  smoke.push(smokePuff);
2297
  }
2298
 
2299
- // 폭발음 μž¬μƒ - 150% μŒλŸ‰
2300
- try {
2301
- const explosionSound = new Audio('sounds/bang.ogg');
2302
- explosionSound.volume = 1.0;
2303
- explosionSound.play().catch(e => console.log('Explosion sound failed:', e));
2304
- } catch (e) {
2305
- console.log('Explosion sound error:', e);
2306
- }
2307
-
2308
  // μ• λ‹ˆλ©”μ΄μ…˜
2309
  const animateExplosion = () => {
2310
  let allDead = true;
@@ -2462,10 +2473,15 @@ class Game {
2462
 
2463
  this.checkCollisions();
2464
 
2465
- if (this.fighter.health <= 0 && this.fighter.position.y <= 0) {
2466
- this.endGame(false, "GROUND COLLISION");
2467
- return;
2468
- }
 
 
 
 
 
2469
 
2470
  this.updateUI();
2471
  this.updateRadar();
 
2070
  }
2071
 
2072
  checkCollisions() {
2073
+ // ν”Œλ ˆμ΄μ–΄ νƒ„ν™˜ vs 적기 좩돌
2074
+ for (let i = this.fighter.bullets.length - 1; i >= 0; i--) {
2075
+ const bullet = this.fighter.bullets[i];
2076
+
2077
+ for (let j = this.enemies.length - 1; j >= 0; j--) {
2078
+ const enemy = this.enemies[j];
2079
+ if (!enemy.mesh || !enemy.isLoaded) continue;
2080
+
2081
+ const distance = bullet.position.distanceTo(enemy.position);
2082
+ if (distance < 90) {
2083
+ // 히트 ν‘œμ‹œ μΆ”κ°€
2084
+ this.showHitMarker(enemy.position);
2085
+ // 피격 μ΄νŽ™νŠΈ μΆ”κ°€
2086
+ this.createHitEffect(enemy.position);
2087
 
2088
+ // νƒ„ν™˜ μ œκ±°λŠ” μ΄νŽ™νŠΈ 생성 후에
2089
+ this.scene.remove(bullet);
2090
+ this.fighter.bullets.splice(i, 1);
2091
+
2092
+ if (enemy.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) {
2093
+ // 적기 파괴 μ‹œ 폭발 효과 μΆ”κ°€ - μœ„μΉ˜ 확인
2094
+ this.createExplosionEffect(enemy.position);
 
 
 
2095
 
2096
+ enemy.destroy();
2097
+ this.enemies.splice(j, 1);
2098
+ this.score += 100;
 
 
 
2099
  }
2100
+ break;
2101
  }
2102
  }
2103
+ }
2104
+
2105
+ // 적 νƒ„ν™˜ vs ν”Œλ ˆμ΄μ–΄ 좩돌
2106
+ this.enemies.forEach(enemy => {
2107
+ for (let index = enemy.bullets.length - 1; index >= 0; index--) {
2108
+ const bullet = enemy.bullets[index];
2109
+ const distance = bullet.position.distanceTo(this.fighter.position);
2110
+ if (distance < 100) {
2111
+ // ν”Œλ ˆμ΄μ–΄ 피격 μ΄νŽ™νŠΈ
2112
+ this.createHitEffect(this.fighter.position);
2113
+
2114
+ // νƒ„ν™˜ 제거
2115
+ this.scene.remove(bullet);
2116
+ enemy.bullets.splice(index, 1);
2117
+
2118
+ if (this.fighter.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) {
2119
+ // ν”Œλ ˆμ΄μ–΄ 파괴 μ‹œ 폭발 효과 μΆ”κ°€
2120
+ this.createExplosionEffect(this.fighter.position);
2121
 
2122
+ this.endGame(false);
 
 
2123
  }
2124
  }
2125
+ }
2126
+ });
2127
+ }
2128
 
2129
  createHitEffect(position) {
2130
  // 피격 νŒŒν‹°ν΄ 효과 생성
 
2221
  }
2222
 
2223
  createExplosionEffect(position) {
2224
+ // ν­λ°œμŒμ„ κ°€μž₯ λ¨Όμ € μž¬μƒ (μ‹œκ°νš¨κ³Όλ³΄λ‹€ μš°μ„ )
2225
+ try {
2226
+ const explosionSound = new Audio('sounds/bang.ogg');
2227
+ explosionSound.volume = 1.0; // μ΅œλŒ€ μŒλŸ‰
2228
+
2229
+ // μ¦‰μ‹œ μž¬μƒ μ‹œλ„
2230
+ const playPromise = explosionSound.play();
2231
+ if (playPromise !== undefined) {
2232
+ playPromise.catch(e => console.log('Explosion sound failed:', e));
2233
+ }
2234
+ } catch (e) {
2235
+ console.log('Explosion sound error:', e);
2236
+ }
2237
+
2238
  // 메인 폭발 ν”Œλž˜μ‹œ
2239
  const explosionGeometry = new THREE.SphereGeometry(50, 16, 16);
2240
  const explosionMaterial = new THREE.MeshBasicMaterial({
 
2316
  smoke.push(smokePuff);
2317
  }
2318
 
 
 
 
 
 
 
 
 
 
2319
  // μ• λ‹ˆλ©”μ΄μ…˜
2320
  const animateExplosion = () => {
2321
  let allDead = true;
 
2473
 
2474
  this.checkCollisions();
2475
 
2476
+ if (this.fighter.health <= 0) {
2477
+
2478
+ if (this.fighter.position.y <= 0) {
2479
+ this.endGame(false, "GROUND COLLISION");
2480
+ } else {
2481
+ this.endGame(false);
2482
+ }
2483
+ return;
2484
+ }
2485
 
2486
  this.updateUI();
2487
  this.updateRadar();