From f33c911e59b0df8a0058451533629f2065c47e8c Mon Sep 17 00:00:00 2001 From: OfficialCHenry Date: Mon, 9 May 2022 02:40:41 -0400 Subject: [PATCH] reverted jump system --- .../Player/PlayerStates/Fall.ts | 1 + .../Player/PlayerStates/Jump.ts | 19 +++++++------------ .../Player/PlayerStates/OnGround.ts | 1 + .../Player/PlayerStates/PlayerState.ts | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/shattered_sword/Player/PlayerStates/Fall.ts b/src/shattered_sword/Player/PlayerStates/Fall.ts index f3d35ac..1c898c5 100644 --- a/src/shattered_sword/Player/PlayerStates/Fall.ts +++ b/src/shattered_sword/Player/PlayerStates/Fall.ts @@ -31,6 +31,7 @@ export default class Fall extends InAir { if( this.parent.airjumps>0 && InputWrapper.isJumpJustPressed()){ this.parent.airjumps --; this.finished("jump"); + this.parent.velocity.y = -600; // basically jump height } super.update(deltaT); } diff --git a/src/shattered_sword/Player/PlayerStates/Jump.ts b/src/shattered_sword/Player/PlayerStates/Jump.ts index 1f21cc3..8e26645 100644 --- a/src/shattered_sword/Player/PlayerStates/Jump.ts +++ b/src/shattered_sword/Player/PlayerStates/Jump.ts @@ -8,16 +8,11 @@ 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; } @@ -42,18 +37,18 @@ export default class Jump extends InAir { this.parent.velocity.y = 0; this.finished(PlayerStates.FALL); } + + 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); } - if (!this.jumpTimer.isStopped() && !this.jumpTimer.isPaused() && InputWrapper.isJumpPressed()) { - this.parent.velocity.y = -400; - } - else { - this.jumpTimer.pause(); - } - super.update(deltaT); } diff --git a/src/shattered_sword/Player/PlayerStates/OnGround.ts b/src/shattered_sword/Player/PlayerStates/OnGround.ts index 9a2bee6..5f1ff15 100644 --- a/src/shattered_sword/Player/PlayerStates/OnGround.ts +++ b/src/shattered_sword/Player/PlayerStates/OnGround.ts @@ -30,6 +30,7 @@ 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 c050b5f..01efa76 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 = 2500; //TODO - can change later + gravity: number = 1500; //TODO - can change later parent: PlayerController; positionTimer: Timer; static dashTimer: Timer;