reverted jump system

This commit is contained in:
OfficialCHenry 2022-05-09 02:40:41 -04:00
parent 30bcbbae3b
commit f33c911e59
4 changed files with 10 additions and 13 deletions

View File

@ -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);
}

View File

@ -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<string, any>): 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);
}

View File

@ -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){

View File

@ -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;