diff --git a/src/main.js b/src/main.js index e6d42dc..593c3e3 100644 --- a/src/main.js +++ b/src/main.js @@ -67,10 +67,6 @@ const HP = 999 const MP = 99 const temp_timer = 400 -// // initialize a boolean value to check if player has attacked -// let player_attack = false -// // check if it is the player's turn (start off with the player going first) -// let player_turn = true // let cursors = null diff --git a/src/prefabs/Health.js b/src/prefabs/Health.js index c858d38..ffce525 100644 --- a/src/prefabs/Health.js +++ b/src/prefabs/Health.js @@ -30,7 +30,6 @@ class HealthBar extends Phaser.GameObjects.Graphics{ scene.add.bitmapText(this.name_pos, this.y + 1, 'font', character.name, 12).setTint(0x1a1200) scene.add.bitmapText(this.name_pos, this.y, 'font', character.name, 12).setTint(0xa8832a) - this.health_txt = scene.add.bitmapText(this.health_pos, this.y - 8, 'font', character.health, 8) } @@ -49,14 +48,6 @@ class HealthBar extends Phaser.GameObjects.Graphics{ } draw() { - // this.bar.clear() - - // BG of the bar - a container for the health - // Note: should design a container for health - // this.bar.fillStyle(0x000000) - // this.bar.fillRect(this.x, this.y, this.width, this.height); - // health - // this.add.image(this.x, this.y, 'health_bar') this.bar.fillStyle(0xabaca7) //#cb3938 @@ -70,9 +61,7 @@ class HealthBar extends Phaser.GameObjects.Graphics{ this.bar.fillStyle(0xcb3938) } - var health_width = Math.floor(this.value / 8.7) - this.bar.fillRect(this.x + 2, this.y + 2, health_width, this.height - this.padding) } } \ No newline at end of file diff --git a/src/prefabs/Projectile.js b/src/prefabs/Projectile.js index c8b81ff..97527fd 100644 --- a/src/prefabs/Projectile.js +++ b/src/prefabs/Projectile.js @@ -1,13 +1,11 @@ class Projectile extends Phaser.Physics.Arcade.Sprite{ constructor(scene, x, y, texture, character){ super(scene, x, y, texture) - // Note: might add health decrease in projectile // projectile will spawn on player scene.add.existing(this) scene.physics.add.existing(this) - - + // initialize variables this.moveSpeed = 250 this.character = character this.startX = this.x @@ -65,7 +63,4 @@ class Projectile extends Phaser.Physics.Arcade.Sprite{ return true } - // update() { - // this.move(scene.enemyX, scene.enemyY) - // } } \ No newline at end of file diff --git a/src/prefabs/Selection.js b/src/prefabs/Selection.js index 1b51b5a..4c9ed86 100644 --- a/src/prefabs/Selection.js +++ b/src/prefabs/Selection.js @@ -15,6 +15,7 @@ class SelectionMenu extends Phaser.GameObjects.Graphics{ this.cursor_pos = -20 // initializing temporary selection button + //see: https://github.com/phaserjs/examples/blob/master/public/src/game%20objects/text/simple%20text%20button.js this.container_bg = scene.add.image(x,y - 4, 'container') this.cursorImage = scene.add.image(x + -36, y + this.cursor_pos, 'cursor').setOrigin(0.5, 0) @@ -66,7 +67,6 @@ class SelectionMenu extends Phaser.GameObjects.Graphics{ } lookChoice(input) { - // selection menu options // if up and down selected then scroll through options this.selections[this.current_selection].clearTint() diff --git a/src/scenes/Fighting.js b/src/scenes/Fighting.js index befe744..412a75a 100644 --- a/src/scenes/Fighting.js +++ b/src/scenes/Fighting.js @@ -6,11 +6,9 @@ class Fighting extends Phaser.Scene { init() { this.hp = HP this.mp = MP - - // check if it is the player's turn (start off with the player going first) + // boolean to check if it is the player's turn (start off with the player going first) this.player_turn = true - this.active_players = 3 // Note: with more scenes turn this into a global variable this.active_enemies = 1 // Note: in future scenes it may change the amount this.FSM_holder = Array(3).fill(0) @@ -72,6 +70,7 @@ class Fighting extends Phaser.Scene { } // restart game if game over if (this.gameOver){ + // check gameover condition if (this.active_enemies == 0){ if (!this.textAdded){ this.add.bitmapText(centerX, centerY, 'font', 'YOU WIN', 20).setOrigin(0.5) @@ -80,18 +79,15 @@ class Fighting extends Phaser.Scene { } } - // use boolean value to ensure that browser does not lag if (this.active_players == 0){ + // use boolean value to ensure that browser does not lag if (!this.textAdded){ this.add.bitmapText(centerX, centerY, 'font', 'GAME OVER', 20).setOrigin(0.5) this.add.bitmapText(centerX, centerY - tileSize, 'font', 'up for menu right to restart', 8).setOrigin(0.5) this.textAdded = true - } } - - if (up.isDown){ this.music.stop() this.scene.start('menuScene') @@ -110,13 +106,6 @@ class Fighting extends Phaser.Scene { this.FSM_holder[1].step() this.FSM_holder[2].step() this.enemyFSM.step() - - // // probably put inside of the character - // if (this.enemy.attacking == false) { - // this.anais.hurt = false - // this.darwin.hurt = false - // this.gumball.hurt = false - // } if (Phaser.Input.Keyboard.JustDown(space)){ this.selectionMenu.select()