ProPerNounpYK commited on
Commit
d2e7ed5
·
verified ·
1 Parent(s): 22f0a02

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +39 -28
index.html CHANGED
@@ -225,21 +225,27 @@ if (enemiesRemaining <= 0 && enemies.length === 0) {
225
 
226
  // 총알이 플레이어와 충돌했을 경우 처리
227
  if (
228
- bullet.x < player.x + player.width - 30 &&
229
- bullet.x + bullet.width > player.x + 30 &&
230
- bullet.y < player.y + player.height - 30 &&
231
- bullet.y + bullet.height > player.y + 30
232
- ) {
233
- player.health--;
234
- healthFill.style.width = (player.health / 5 * 100) + '%';
235
- player.image.src = player.direction === 1 ? player.imageHitRight : player.imageHitLeft;
236
- enemyBullets.splice(index, 1); // 총알 제거
237
- playerHitSound.play();
238
 
239
- if (player.health <= 0) {
240
- endGame("Game Over! Go back to the past and change the current result!");
241
- }
242
- }
 
 
 
 
 
 
 
 
 
243
  });
244
 
245
  // 화면 밖으로 나간 총알 제거
@@ -320,20 +326,25 @@ if (enemiesRemaining <= 0 && enemies.length === 0) {
320
  if (player.x < canvas.width - player.width) player.x += player.speed;
321
  break;
322
  case ' ':
323
- if (player.bullets > 0) {
324
- player.image.src = player.direction === 1 ? player.imageShootRight : player.imageShootLeft;
325
- bullets.push({
326
- x: player.x + player.width / 2,
327
- y: player.y + player.height / 2.5,
328
- width: 10,
329
- height: 5,
330
- speed: player.direction * 10
331
- });
332
- player.bullets--;
333
- bulletCount.textContent = player.bullets;
334
- playerShootSound.play();
335
- }
336
- break;
 
 
 
 
 
337
  }
338
  }
339
  });
 
225
 
226
  // 총알이 플레이어와 충돌했을 경우 처리
227
  if (
228
+ bullet.x < player.x + player.width - 30 &&
229
+ bullet.x + bullet.width > player.x + 30 &&
230
+ bullet.y < player.y + player.height - 30 &&
231
+ bullet.y + bullet.height > player.y + 30
232
+ ) {
233
+ player.health--;
234
+ healthFill.style.width = (player.health / 5 * 100) + '%';
 
 
 
235
 
236
+ const hitImage = player.direction === 1 ? player.imageHitRight : player.imageHitLeft;
237
+ player.image.src = hitImage; // 맞은 이미지로 변경
238
+ setTimeout(() => {
239
+ player.image.src = player.direction === 1 ? player.imageRight : player.imageLeft; // 1초 후 기본 이미지로 복원
240
+ }, 1000);
241
+
242
+ enemyBullets.splice(index, 1); // 총알 제거
243
+ playerHitSound.play();
244
+
245
+ if (player.health <= 0) {
246
+ endGame("Game Over! Go back to the past and change the current result!");
247
+ }
248
+ }
249
  });
250
 
251
  // 화면 밖으로 나간 총알 제거
 
326
  if (player.x < canvas.width - player.width) player.x += player.speed;
327
  break;
328
  case ' ':
329
+ if (player.bullets > 0) {
330
+ const shootImage = player.direction === 1 ? player.imageShootRight : player.imageShootLeft;
331
+ player.image.src = shootImage; // 발사 이미지로 변경
332
+ setTimeout(() => {
333
+ player.image.src = player.direction === 1 ? player.imageRight : player.imageLeft; // 1초 후 기본 이미지로 복원
334
+ }, 1000);
335
+
336
+ bullets.push({
337
+ x: player.x + player.width / 2,
338
+ y: player.y + player.height / 2.5,
339
+ width: 10,
340
+ height: 5,
341
+ speed: player.direction * 10
342
+ });
343
+ player.bullets--;
344
+ bulletCount.textContent = player.bullets;
345
+ playerShootSound.play();
346
+ }
347
+ break;
348
  }
349
  }
350
  });