KaiShin1885 commited on
Commit
0f1343b
·
verified ·
1 Parent(s): 63d60ca

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +11 -3
index.html CHANGED
@@ -172,7 +172,7 @@
172
  };
173
 
174
  const SPRITES = {
175
- stand: ['kstand1.png', 'kstand2.png']
176
  };
177
 
178
  class Character {
@@ -275,6 +275,7 @@
275
  if (!defender.isBlocking) {
276
  defender.health -= SETTINGS.DAMAGE;
277
  this.updateHealthBars();
 
278
  }
279
  }, SETTINGS.ATTACK_DELAY);
280
 
@@ -297,6 +298,7 @@
297
  if (!defender.isBlocking) {
298
  defender.health -= SETTINGS.SPECIAL_DAMAGE;
299
  this.updateHealthBars();
 
300
  }
301
  ultimateEl.remove();
302
  }, 300);
@@ -395,9 +397,15 @@
395
 
396
  updateHealthBars() {
397
  document.getElementById('playerHealthFill').style.width =
398
- `${(this.player.health/SETTINGS.INITIAL_HEALTH)*100}%`;
399
  document.getElementById('enemyHealthFill').style.width =
400
- `${(this.enemy.health/SETTINGS.INITIAL_HEALTH)*100}%`;
 
 
 
 
 
 
401
  }
402
 
403
  startGame() {
 
172
  };
173
 
174
  const SPRITES = {
175
+ stand: ['kstand1.png', 'kstand2.png', 'kstand3.png']
176
  };
177
 
178
  class Character {
 
275
  if (!defender.isBlocking) {
276
  defender.health -= SETTINGS.DAMAGE;
277
  this.updateHealthBars();
278
+ this.checkGameOver();
279
  }
280
  }, SETTINGS.ATTACK_DELAY);
281
 
 
298
  if (!defender.isBlocking) {
299
  defender.health -= SETTINGS.SPECIAL_DAMAGE;
300
  this.updateHealthBars();
301
+ this.checkGameOver();
302
  }
303
  ultimateEl.remove();
304
  }, 300);
 
397
 
398
  updateHealthBars() {
399
  document.getElementById('playerHealthFill').style.width =
400
+ `${(this.player.health / SETTINGS.INITIAL_HEALTH) * 100}%`;
401
  document.getElementById('enemyHealthFill').style.width =
402
+ `${(this.enemy.health / SETTINGS.INITIAL_HEALTH) * 100}%`;
403
+ }
404
+
405
+ checkGameOver() {
406
+ if (this.player.health <= 0 || this.enemy.health <= 0) {
407
+ this.endGame();
408
+ }
409
  }
410
 
411
  startGame() {