diff --git a/assets/penny_spritesheet.png b/assets/penny_spritesheet.png index d6647dc..e5dd3a3 100644 Binary files a/assets/penny_spritesheet.png and b/assets/penny_spritesheet.png differ diff --git a/src/prefabs/Character.js b/src/prefabs/Character.js index 2f75bf9..6cd6abb 100644 --- a/src/prefabs/Character.js +++ b/src/prefabs/Character.js @@ -42,11 +42,6 @@ class IdleState extends State { // player is not attacking in idle state scene.dmgToEnemy = 0 character.clearTint() - // if (character.hasAttacked){ - // // console.log('no attacky') - // } - - // character.hasAttacked = false } execute(scene, character) { @@ -102,13 +97,17 @@ class HurtState extends State { // decrease health and update bar character.health -= scene.enemy.dmgToPlayer scene.characters_hp[scene.enemy.selectedChar].match(character.health) - let damage = scene.add.bitmapText(character.x, character.y - tileSize*1.5, 'font', -scene.enemy.dmgToPlayer, 8).setOrigin(0, 0).setTint(0xFF0000) - + let damage_txt = scene.add.bitmapText(character.x, character.y - tileSize*1.5, 'font', -scene.enemy.dmgToPlayer, 8).setOrigin(0, 0).setTint(0xFF0000) + + this.attackText_below = scene.add.bitmapText(centerX, centerY+1, 'font', `${character.name} takes ${-scene.enemy.dmgToPlayer} damage`, 12).setOrigin(0.5).setTint(0x1a1200) + this.attackText = scene.add.bitmapText(centerX, centerY, 'font', `${character.name} takes ${-scene.enemy.dmgToPlayer} damage`, 12).setOrigin(0.5) if (character.health > 0){ scene.time.delayedCall(character.hurtTimer, () => { character.clearTint() scene.enemy.attacking = false - damage.setVisible(false) + damage_txt.setVisible(false) + this.attackText_below.setVisible(false) + this.attackText.setVisible(false) if (character.health > 0){ this.stateMachine.transition('idle') diff --git a/src/prefabs/Enemy.js b/src/prefabs/Enemy.js index b70093e..006f9c7 100644 --- a/src/prefabs/Enemy.js +++ b/src/prefabs/Enemy.js @@ -18,7 +18,6 @@ class Enemy extends Phaser.GameObjects.Sprite { // setting up the character to attack this.selectedChar = -1 - // this.damaged = false // setting up state machines scene.enemyFSM = new StateMachine('default', { @@ -47,7 +46,7 @@ class DefaultState extends State { // ensure enemy is not attacking in this scene enemy.hasAttacked = false enemy.dmgToPlayer = 0 - scene.enemy_attacking + // scene.player_turn = true enemy.clearTint() enemy.anims.play(`${enemy.name}_default`, true) @@ -82,24 +81,23 @@ class SingleAttackState extends State { // enemy will randomize their attack on a character enter (scene, enemy) { // the damage to player becomes the attack power of this enemy + enemy.anims.play(`${enemy.name}_singleAttack`, true) + scene.time.delayedCall(enemy.damagedTimer, () => { enemy.dmgToPlayer = enemy.attack_dmg enemy.hasAttacked = true }) enemy.selectedChar = enemy.charAttacking(scene.checkLiving()) scene.characters[enemy.selectedChar].hurt = true - // enemy.hasAttacked = true - this.attackText_below = scene.add.bitmapText(centerX, centerY+1, 'font', `${scene.characters[enemy.selectedChar].name} takes ${enemy.dmgToPlayer} damage`, 12).setOrigin(0.5).setTint(0x1a1200) - this.attackText = scene.add.bitmapText(centerX, centerY, 'font', `${scene.characters[enemy.selectedChar].name} takes ${enemy.dmgToPlayer} damage`, 12).setOrigin(0.5) - + } execute(scene, enemy) { if (enemy.hasAttacked == true) { - // reset the selected char here (TEMP) + // PROBLEM + + // reset the selected char here this.selectedChar = -1 scene.changeTurn() - this.attackText_below.setVisible(false) - this.attackText.setVisible(false) this.stateMachine.transition('default') } } @@ -130,7 +128,6 @@ class DamagedState extends State { class DefeatState extends State { // the enemy will be knocked out in this state enter (scene, enemy) { - // maybe increase a variable to check how many players have defeatd enemy.anims.play(`${enemy.name}_defeat`, true) // enemy.setTint('#A020F0') scene.active_enemies -= 1 diff --git a/src/prefabs/Selection.js b/src/prefabs/Selection.js index 4c9ed86..1fb36a7 100644 --- a/src/prefabs/Selection.js +++ b/src/prefabs/Selection.js @@ -14,7 +14,6 @@ class SelectionMenu extends Phaser.GameObjects.Graphics{ this.current_selection = 2 // what the cursor is pointing at 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') @@ -27,7 +26,7 @@ class SelectionMenu extends Phaser.GameObjects.Graphics{ this.availableChar = this.scene.checkActive() this.charCursor = scene.add.image(this.characters[this.current_player].x + 15, this.characters[this.current_player].y - tileSize * 1.5, 'char_cursor') - this.attackingPlayer + this.attackingPlayer = undefined // initialize an attacking Player } updateAvailable() { diff --git a/src/scenes/Fighting.js b/src/scenes/Fighting.js index 412a75a..223e889 100644 --- a/src/scenes/Fighting.js +++ b/src/scenes/Fighting.js @@ -13,7 +13,6 @@ class Fighting extends Phaser.Scene { this.active_enemies = 1 // Note: in future scenes it may change the amount this.FSM_holder = Array(3).fill(0) this.textAdded = false - this.temp_dmg = 200 // initializing the amt the player will do to the enemy this.dmgToEnemy = 0 this.enemy_dmg = 0 diff --git a/src/scenes/Menu.js b/src/scenes/Menu.js index 5e09a87..3b31105 100644 --- a/src/scenes/Menu.js +++ b/src/scenes/Menu.js @@ -147,16 +147,22 @@ class Menu extends Phaser.Scene{ frames: this.anims.generateFrameNumbers('penny', { start: 0, end:7}), }) this.anims.create({ - key: 'PENNY_damaged', + key: 'PENNY_singleAttack', frameRate: 8, repeat: 0, frames: this.anims.generateFrameNumbers('penny', { start: 8, end:15}), }) + this.anims.create({ + key: 'PENNY_damaged', + frameRate: 8, + repeat: 0, + frames: this.anims.generateFrameNumbers('penny', { start: 16, end:23}), + }) this.anims.create({ key: 'PENNY_defeat', frameRate: 8, repeat: -1, - frames: this.anims.generateFrameNumbers('penny', { start: 16, end: 16}), + frames: this.anims.generateFrameNumbers('penny', { start: 24, end: 24}), }) }