ProPerNounpYK commited on
Commit
dfe502e
ยท
verified ยท
1 Parent(s): 07055c9

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +35 -32
index.html CHANGED
@@ -105,23 +105,23 @@
105
  canvas.height = window.innerHeight;
106
 
107
  const player = {
108
- x: canvas.width / 2.3,
109
- y: canvas.height - 260,
110
- width: 250,
111
- height: 250,
112
- speed: 10,
113
- health: 5,
114
- bullets: 35,
115
- direction: 1,
116
- image: new Image(),
117
- imageLeft: 'Maincharacterdefaultleft.png',
118
- imageRight: 'Maincharacterdefaultright.png',
119
- imageShootLeft: 'Maincharactergunshotleft.png',
120
- imageShootRight: 'Maincharactergunshotright.png',
121
- imageHitLeft: 'MainCharacterExplosionLeft.png',
122
- imageHitRight: 'MainCharacterExplosionRight.png'
123
- };
124
- player.image.src = player.imageRight;
125
 
126
  let enemies = [];
127
  let bullets = [];
@@ -209,27 +209,30 @@
209
  });
210
 
211
  // ์  ์ด์•Œ ์—…๋ฐ์ดํŠธ
212
- enemyBullets.forEach((bullet) => {
213
- bullet.x += bullet.speed;
214
- ctx.fillStyle = 'orange';
215
- ctx.fillRect(bullet.x, bullet.y, bullet.width, bullet.height);
216
 
217
- if (
218
- bullet.x < player.x + player.width - 30 &&
219
- bullet.x + bullet.width > player.x + 30 &&
220
- bullet.y < player.y + player.height - 30 &&
221
- bullet.y + bullet.height > player.y + 30
222
- ) {
223
- player.health--; // ํ”Œ๋ ˆ์ด์–ด ์ฒด๋ ฅ ๊ฐ์†Œ
224
  healthFill.style.width = (player.health / 5 * 100) + '%'; // ์ฒด๋ ฅ ๋ฐ” ์—…๋ฐ์ดํŠธ
225
  player.image.src = player.direction === 1 ? player.imageHitRight : player.imageHitLeft;
226
  playerHitSound.play();
227
 
228
- if (player.health <= 0) {
229
- endGame("Game Over! Go back to the past and change the current result!");
230
- }
231
  }
232
- });
 
 
 
 
233
  // ํ™”๋ฉด ๋ฐ– ์  ์ด์•Œ ์ œ๊ฑฐ
234
  enemyBullets = enemyBullets.filter(bullet => bullet.x >= 0 && bullet.x <= canvas.width);
235
 
 
105
  canvas.height = window.innerHeight;
106
 
107
  const player = {
108
+ x: canvas.width / 2.3,
109
+ y: canvas.height - 260,
110
+ width: 250,
111
+ height: 250,
112
+ speed: 10,
113
+ health: 5, // ํ”Œ๋ ˆ์ด์–ด ์ฒด๋ ฅ์„ 5๋กœ ์„ค์ •
114
+ bullets: 35,
115
+ direction: 1,
116
+ image: new Image(),
117
+ imageLeft: 'Maincharacterdefaultleft.png',
118
+ imageRight: 'Maincharacterdefaultright.png',
119
+ imageShootLeft: 'Maincharactergunshotleft.png',
120
+ imageShootRight: 'Maincharactergunshotright.png',
121
+ imageHitLeft: 'MainCharacterExplosionLeft.png',
122
+ imageHitRight: 'MainCharacterExplosionRight.png'
123
+ };
124
+ player.image.src = player.imageRight;
125
 
126
  let enemies = [];
127
  let bullets = [];
 
209
  });
210
 
211
  // ์  ์ด์•Œ ์—…๋ฐ์ดํŠธ
212
+ enemyBullets.forEach((bullet) => {
213
+ bullet.x += bullet.speed;
214
+ ctx.fillStyle = 'orange';
215
+ ctx.fillRect(bullet.x, bullet.y, bullet.width, bullet.height);
216
 
217
+ if (
218
+ bullet.x < player.x + player.width - 30 &&
219
+ bullet.x + bullet.width > player.x + 30 &&
220
+ bullet.y < player.y + player.height - 30 &&
221
+ bullet.y + bullet.height > player.y + 30
222
+ ) {
223
+ player.health--; // ํ”Œ๋ ˆ์ด์–ด ์ฒด๋ ฅ ๊ฐ์†Œ
224
  healthFill.style.width = (player.health / 5 * 100) + '%'; // ์ฒด๋ ฅ ๋ฐ” ์—…๋ฐ์ดํŠธ
225
  player.image.src = player.direction === 1 ? player.imageHitRight : player.imageHitLeft;
226
  playerHitSound.play();
227
 
228
+ if (player.health <= 0) {
229
+ endGame("Game Over! Go back to the past and change the current result!"); // ์ฒด๋ ฅ์ด 0์ด ๋˜๋ฉด ๊ฒŒ์ž„ ์˜ค๋ฒ„
 
230
  }
231
+ }
232
+ });
233
+
234
+ // ์ฒด๋ ฅ ๋ฐ”๋ฅผ ์ดˆ๊ธฐํ™”ํ•  ๋•Œ
235
+ healthFill.style.width = (player.health / 5 * 100) + '%';
236
  // ํ™”๋ฉด ๋ฐ– ์  ์ด์•Œ ์ œ๊ฑฐ
237
  enemyBullets = enemyBullets.filter(bullet => bullet.x >= 0 && bullet.x <= canvas.width);
238