Skip to content

Commit

Permalink
Merging Branches With New Spritesheet and Fixed Visuals
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlizeSerrano5 committed Mar 14, 2024
1 parent a532208 commit 5a3c9df
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
Binary file modified assets/penny_spritesheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions src/prefabs/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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')
Expand Down
17 changes: 7 additions & 10 deletions src/prefabs/Enemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
}
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/prefabs/Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion src/scenes/Fighting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/scenes/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
})

}
Expand Down

0 comments on commit 5a3c9df

Please sign in to comment.