Skip to content

Commit

Permalink
Attempted to add listeners to the pirate class
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikketer committed Jul 9, 2024
1 parent 3dc5509 commit eba479d
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions pirate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
class Pirate {
static idleRightSprite: Image = assets.image`Pirate`
static idleLeftSprite: Image = assets.image`Pirate`
static attackRightSprite: Image = assets.image`Pirate`
static attackLeftSprite: Image = assets.image`Pirate`
static parryRightSprite: Image = assets.image`Pirate`
static attackLeftAnimation: Image[] = assets.animation`Pirate Swing w Sword`.map((frame: Image) => {
frame.flipX()
return frame
})
static attackRightAnimation: Image[] = assets.animation`Pirate Swing w Sword`
static parryLeftSprite: Image = assets.image`Pirate`
static parryRightSprite: Image = assets.image`Pirate`
static walkRightSprite: Image = assets.image`Pirate`
static walkLeftSprite: Image = assets.image`Pirate`

Expand All @@ -24,6 +27,8 @@ class Pirate {
animation.runImageAnimation(this.currentSprite, assets.animation`Pirate Stand`, 300, true)

// Setup the controller handlers
// console.log('This ' + this.attack)
this._controller.A.addEventListener(ControllerButtonEvent.Pressed, this.attack)
}

public place(x: number, y: number) {
Expand All @@ -36,7 +41,21 @@ class Pirate {
// Remove all event listeners
}

public attack() { }

public render() { }

attack() {
console.log("Attack!" + this.health)
const attackAnimationSpeed = 50
// const anim = this.facing === 'right' ?
// Pirate.attackRightAnimation :
// Pirate.attackLeftAnimation

// animation.runImageAnimation(
// this.currentSprite,
// anim,
// attackAnimationSpeed,
// false
// )
// pause(anim.length * attackAnimationSpeed)
}
}

0 comments on commit eba479d

Please sign in to comment.