diff --git a/src/shattered_sword/Player/PlayerStates/Idle.ts b/src/shattered_sword/Player/PlayerStates/Idle.ts index 8dd737b..e2cfa2d 100644 --- a/src/shattered_sword/Player/PlayerStates/Idle.ts +++ b/src/shattered_sword/Player/PlayerStates/Idle.ts @@ -11,7 +11,7 @@ export default class Idle extends OnGround { update(deltaT: number): void { - super.update(deltaT); + this.owner.animation.playIfNotAlready("IDLE", true); @@ -22,7 +22,7 @@ export default class Idle extends OnGround { } this.parent.velocity.x = 0; - + super.update(deltaT); this.owner.move(this.parent.velocity.scaled(deltaT)); } diff --git a/src/shattered_sword/Player/PlayerStates/OnGround.ts b/src/shattered_sword/Player/PlayerStates/OnGround.ts index 59439e5..fa0c518 100644 --- a/src/shattered_sword/Player/PlayerStates/OnGround.ts +++ b/src/shattered_sword/Player/PlayerStates/OnGround.ts @@ -16,7 +16,7 @@ export default class OnGround extends PlayerState { } - super.update(deltaT); + let direction = this.getInputDirection(); @@ -34,7 +34,8 @@ export default class OnGround extends PlayerState { else if(!this.owner.onGround){ this.finished("fall"); } - + super.update(deltaT); + this.owner.move(this.parent.velocity.scaled(deltaT)); } diff --git a/src/shattered_sword/Player/PlayerStates/PlayerState.ts b/src/shattered_sword/Player/PlayerStates/PlayerState.ts index bcb54a1..2a46f09 100644 --- a/src/shattered_sword/Player/PlayerStates/PlayerState.ts +++ b/src/shattered_sword/Player/PlayerStates/PlayerState.ts @@ -3,6 +3,7 @@ import StateMachine from "../../../Wolfie2D/DataTypes/State/StateMachine"; import Vec2 from "../../../Wolfie2D/DataTypes/Vec2"; import GameEvent from "../../../Wolfie2D/Events/GameEvent"; import GameNode from "../../../Wolfie2D/Nodes/GameNode"; +import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; import Timer from "../../../Wolfie2D/Timing/Timer"; import { Player_Events } from "../../sword_enums"; import InputWrapper from "../../Tools/InputWrapper"; @@ -14,12 +15,16 @@ export default abstract class PlayerState extends State { gravity: number = 1500; //TODO - can change later parent: PlayerController; positionTimer: Timer; + static dashTimer: Timer; + static dashCoolDownTimer: Timer; constructor(parent: StateMachine, owner: GameNode){ super(parent); this.owner = owner; this.positionTimer = new Timer(250); this.positionTimer.start(); + PlayerState.dashTimer = new Timer(50); + PlayerState.dashCoolDownTimer = new Timer(600); } @@ -27,6 +32,17 @@ export default abstract class PlayerState extends State { } + doDash(): void { + if (PlayerState.dashCoolDownTimer.isStopped()) { + //TODO - decide how to implement dash - could be a flash - maybe allow in air as well + //play dash anim maybe + //TODO - might give buffed speed stat to dash speed + //TODO - give player i frame + PlayerState.dashCoolDownTimer.start(); + PlayerState.dashTimer.start(); + } + } + /** * Get the inputs from the keyboard, or Vec2.Zero if nothing is being pressed */ @@ -47,5 +63,12 @@ export default abstract class PlayerState extends State { this.positionTimer.start(); } this.parent.velocity.y += this.gravity*deltaT; + + if(InputWrapper.isDashJustPressed()){ + this.doDash(); + } + if (!PlayerState.dashTimer.isStopped()) { + this.parent.velocity.x = (this.owner).invertX ? -800 : 800; + } } } \ No newline at end of file diff --git a/src/shattered_sword/Player/PlayerStates/Walk.ts b/src/shattered_sword/Player/PlayerStates/Walk.ts index a1c598d..e00b116 100644 --- a/src/shattered_sword/Player/PlayerStates/Walk.ts +++ b/src/shattered_sword/Player/PlayerStates/Walk.ts @@ -13,7 +13,6 @@ export default class Walk extends OnGround { update(deltaT: number): void { - super.update(deltaT); //console.log("walking anim"); this.owner.animation.playIfNotAlready("WALK", true); @@ -25,14 +24,7 @@ export default class Walk extends OnGround { this.parent.velocity.x = dir.x * (this.parent.speed + this.parent.CURRENT_BUFFS.speed); - //TODO - decide how to implement dash - could be a flash - maybe allow in air as well - if(InputWrapper.isDashJustPressed()){ - //play dash anim maybe - //TODO - might give buffed speed stat to dash speed - this.parent.velocity.x = dir.x * 1000; //give sidewards velocity - //TODO - give player i frame - } - this.owner.move(this.parent.velocity.scaled(deltaT)); + super.update(deltaT); } onExit(): Record {