diff --git a/src/shattered_sword/Player/PlayerStates/Fall.ts b/src/shattered_sword/Player/PlayerStates/Fall.ts index eacefa2..f3d35ac 100644 --- a/src/shattered_sword/Player/PlayerStates/Fall.ts +++ b/src/shattered_sword/Player/PlayerStates/Fall.ts @@ -28,14 +28,10 @@ export default class Fall extends InAir { this.owner.animation.playIfNotAlready("FALL", true); } } - //TODO - testing doublejump, may have to move to InAir instead - // If we jump, move to the Jump state, give a burst of upwards velocity if( this.parent.airjumps>0 && InputWrapper.isJumpJustPressed()){ this.parent.airjumps --; this.finished("jump"); - this.parent.velocity.y = -600; // basically jump height } - super.update(deltaT); } onExit(): Record { diff --git a/src/shattered_sword/Player/PlayerStates/InAir.ts b/src/shattered_sword/Player/PlayerStates/InAir.ts index ff8dfa7..7875799 100644 --- a/src/shattered_sword/Player/PlayerStates/InAir.ts +++ b/src/shattered_sword/Player/PlayerStates/InAir.ts @@ -1,6 +1,7 @@ import GameEvent from "../../../Wolfie2D/Events/GameEvent"; import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; import MathUtils from "../../../Wolfie2D/Utils/MathUtils"; +import InputWrapper from "../../Tools/InputWrapper"; import { PlayerStates } from "../PlayerController"; import PlayerState from "./PlayerState"; diff --git a/src/shattered_sword/Player/PlayerStates/Jump.ts b/src/shattered_sword/Player/PlayerStates/Jump.ts index f90ff39..1f4ac50 100644 --- a/src/shattered_sword/Player/PlayerStates/Jump.ts +++ b/src/shattered_sword/Player/PlayerStates/Jump.ts @@ -8,11 +8,16 @@ import { PlayerStates } from "../PlayerController"; import InAir from "./InAir"; import PlayerState from "./PlayerState"; import { GameState } from "../../sword_enums"; +import Timer from "../../../Wolfie2D/Timing/Timer"; export default class Jump extends InAir { owner: AnimatedSprite; + jumpTimer: Timer; onEnter(options: Record): void { this.emitter.fireEvent(GameEventType.PLAY_SOUND, {key: "jump", loop: false, holdReference: false}); + this.jumpTimer = new Timer(300); + this.jumpTimer.start(); + this.parent.velocity.y = -400; } @@ -33,20 +38,17 @@ export default class Jump extends InAir { } } + + if (!this.jumpTimer.isStopped() && !this.jumpTimer.isPaused() && InputWrapper.isJumpPressed()) { + this.parent.velocity.y = -400; + } + else { + this.jumpTimer.pause(); + } if(this.owner.onCeiling){ this.parent.velocity.y = 0; } - - //TODO - testing doublejump, may have to move to InAir instead - // If we jump, move to the Jump state, give a burst of upwards velocity - if( this.parent.airjumps>0 && InputWrapper.isJumpJustPressed()){ - this.parent.airjumps --; - this.finished("jump"); - this.parent.velocity.y = -600; // basically jump height - - } - // If we're falling, go to the fall state if(this.parent.velocity.y >= 0){ this.finished(PlayerStates.FALL); diff --git a/src/shattered_sword/Player/PlayerStates/OnGround.ts b/src/shattered_sword/Player/PlayerStates/OnGround.ts index 4e5a8e8..9a2bee6 100644 --- a/src/shattered_sword/Player/PlayerStates/OnGround.ts +++ b/src/shattered_sword/Player/PlayerStates/OnGround.ts @@ -30,7 +30,6 @@ export default class OnGround extends PlayerState { // If we jump, move to the Jump state, give a burst of upwards velocity if(InputWrapper.isJumpJustPressed()){ this.finished("jump"); - this.parent.velocity.y = -600; // basically jump height } else if(!this.owner.onGround && InputWrapper.getState() === GameState.GAMING){ diff --git a/src/shattered_sword/Player/PlayerStates/PlayerState.ts b/src/shattered_sword/Player/PlayerStates/PlayerState.ts index 3aa216b..1db2272 100644 --- a/src/shattered_sword/Player/PlayerStates/PlayerState.ts +++ b/src/shattered_sword/Player/PlayerStates/PlayerState.ts @@ -13,7 +13,7 @@ import PlayerController from "../PlayerController"; export default abstract class PlayerState extends State { owner: GameNode; - gravity: number = 1500; //TODO - can change later + gravity: number = 2500; //TODO - can change later parent: PlayerController; positionTimer: Timer; static dashTimer: Timer; diff --git a/src/shattered_sword/Tools/InputWrapper.ts b/src/shattered_sword/Tools/InputWrapper.ts index 7381925..73b0183 100644 --- a/src/shattered_sword/Tools/InputWrapper.ts +++ b/src/shattered_sword/Tools/InputWrapper.ts @@ -56,6 +56,17 @@ export default class InputWrapper { return false; } + static isJumpPressed(): boolean { + if (InputWrapper.gameState != GameState.GAMING) { + return false; + } + + if (Input.isPressed("jump")) { + return true; + } + return false; + } + /** * Returns whether or not the attack key is currently pressed * @returns True if the attack key is pressed, false otherwise