cutechicken commited on
Commit
fcea64b
ยท
verified ยท
1 Parent(s): 55654ec

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +37 -24
game.js CHANGED
@@ -1166,6 +1166,7 @@ update(deltaTime, playerPosition) {
1166
  // ๋ช…์ค‘ ์ฒดํฌ - ๋ฒ”์œ„ ์ฆ๊ฐ€
1167
  if (distance < 50) {
1168
  // ๋ช…์ค‘!
 
1169
  this.onHit();
1170
  return 'hit';
1171
  }
@@ -1234,12 +1235,10 @@ update(deltaTime, playerPosition) {
1234
  // ํƒ€๊ฒŸ์ด ์ง€๋ฉด์— ์žˆ์œผ๋ฉด ๋ฏธ์‚ฌ์ผ๋„ ๋”ฐ๋ผ๊ฐ
1235
  if (this.target.position.y <= 50 && distance < 200) {
1236
  // ํƒ€๊ฒŸ์ด ์ง€๋ฉด ๊ทผ์ฒ˜์— ์žˆ๊ณ  ๊ฑฐ๋ฆฌ๊ฐ€ ๊ฐ€๊นŒ์šฐ๋ฉด ์ฆ‰์‹œ ๋ช…์ค‘
 
1237
  this.onHit();
1238
  return 'hit';
1239
  }
1240
-
1241
- return 'flying';
1242
- }
1243
 
1244
  createSmokeParticle() {
1245
  // ๋ฏธ์‚ฌ์ผ ๋’ค์ชฝ ์œ„์น˜ ๊ณ„์‚ฐ
@@ -1281,27 +1280,41 @@ update(deltaTime, playerPosition) {
1281
  }
1282
 
1283
  onHit() {
1284
- // ๋ช…์ค‘ ํšจ๊ณผ
1285
- if (window.gameInstance) {
1286
- window.gameInstance.createExplosionEffect(this.position);
1287
- }
1288
-
1289
- // ๋ช…์ค‘์Œ
1290
- try {
1291
- const hitSound = new Audio('sounds/missilehit.ogg');
1292
- hitSound.volume = 0.8;
1293
- hitSound.play().catch(e => {});
1294
- } catch (e) {
1295
- console.log('Missile hit sound failed:', e);
1296
- }
1297
-
1298
- // ํƒ€๊ฒŸ์—๊ฒŒ ํ”ผํ•ด
1299
- if (this.target.takeDamage) {
1300
- this.target.takeDamage(GAME_CONSTANTS.AIM9_DAMAGE);
1301
- }
1302
-
1303
- this.destroy();
1304
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1305
 
1306
  destroy() {
1307
  if (this.mesh) {
 
1166
  // ๋ช…์ค‘ ์ฒดํฌ - ๋ฒ”์œ„ ์ฆ๊ฐ€
1167
  if (distance < 50) {
1168
  // ๋ช…์ค‘!
1169
+ console.log('AIM-9 missile hit! Distance:', distance);
1170
  this.onHit();
1171
  return 'hit';
1172
  }
 
1235
  // ํƒ€๊ฒŸ์ด ์ง€๋ฉด์— ์žˆ์œผ๋ฉด ๋ฏธ์‚ฌ์ผ๋„ ๋”ฐ๋ผ๊ฐ
1236
  if (this.target.position.y <= 50 && distance < 200) {
1237
  // ํƒ€๊ฒŸ์ด ์ง€๋ฉด ๊ทผ์ฒ˜์— ์žˆ๊ณ  ๊ฑฐ๋ฆฌ๊ฐ€ ๊ฐ€๊นŒ์šฐ๋ฉด ์ฆ‰์‹œ ๋ช…์ค‘
1238
+ console.log('AIM-9 missile ground proximity hit!');
1239
  this.onHit();
1240
  return 'hit';
1241
  }
 
 
 
1242
 
1243
  createSmokeParticle() {
1244
  // ๋ฏธ์‚ฌ์ผ ๋’ค์ชฝ ์œ„์น˜ ๊ณ„์‚ฐ
 
1280
  }
1281
 
1282
  onHit() {
1283
+ // ๋ช…์ค‘ ํšจ๊ณผ
1284
+ if (window.gameInstance) {
1285
+ window.gameInstance.createExplosionEffect(this.position);
1286
+ }
1287
+
1288
+ // ๋ช…์ค‘์Œ
1289
+ try {
1290
+ const hitSound = new Audio('sounds/missilehit.ogg');
1291
+ hitSound.volume = 0.8;
1292
+ hitSound.play().catch(e => {});
1293
+ } catch (e) {
1294
+ console.log('Missile hit sound failed:', e);
1295
+ }
1296
+
1297
+ // ํƒ€๊ฒŸ์—๊ฒŒ ํ”ผํ•ด - ํ™•์‹คํ•˜๊ฒŒ ํ”ผํ•ด๋ฅผ ์ž…ํžˆ๊ณ  ํŒŒ๊ดด ์ฒ˜๋ฆฌ
1298
+ if (this.target && this.target.takeDamage) {
1299
+ console.log('AIM-9 hitting target, damage:', GAME_CONSTANTS.AIM9_DAMAGE);
1300
+ const isDead = this.target.takeDamage(GAME_CONSTANTS.AIM9_DAMAGE);
1301
+ console.log('Target destroyed:', isDead);
1302
+
1303
+ // ํƒ€๊ฒŸ์ด ํŒŒ๊ดด๋˜์—ˆ๋‹ค๋ฉด ๊ฒŒ์ž„์—์„œ ์ œ๊ฑฐ
1304
+ if (isDead && window.gameInstance) {
1305
+ // ์  ๋ฐฐ์—ด์—์„œ ์ฐพ์•„์„œ ์ œ๊ฑฐ
1306
+ const enemyIndex = window.gameInstance.enemies.indexOf(this.target);
1307
+ if (enemyIndex !== -1) {
1308
+ console.log('Removing destroyed enemy from game');
1309
+ this.target.destroy();
1310
+ window.gameInstance.enemies.splice(enemyIndex, 1);
1311
+ window.gameInstance.score += 100;
1312
+ }
1313
+ }
1314
+ }
1315
+
1316
+ this.destroy();
1317
+ }
1318
 
1319
  destroy() {
1320
  if (this.mesh) {