Skip to content

Instantly share code, notes, and snippets.

@csclyde
Last active September 18, 2017 06:53
Show Gist options
  • Save csclyde/67b6dc2615b610553dcc4907a4bf4a02 to your computer and use it in GitHub Desktop.
Save csclyde/67b6dc2615b610553dcc4907a4bf4a02 to your computer and use it in GitHub Desktop.
Frauki jump
Player.prototype.Jump = function(params) {
if( this.state === this.Hurting ||
this.state === this.AttackDiveLand ||
this.state === this.AttackFall ||
this.state === this.Stunned ||
this.state === this.Throwing)
return;
if(params.jump) {
//drop through cloud tiles
if(inputController.dpad.down && this.states.onCloud && this.state !== this.Rolling) {
this.states.droppingThroughCloud = true;
var dropTime = 200;
if(frauki.states.inWater) dropTime *= 2;
game.time.events.add(dropTime, function() { frauki.states.droppingThroughCloud = false; } );
this.timers.SetTimer('frauki_dash', 250);
return;
}
//normal jump
if( this.state === this.Standing ||
this.state === this.Running ||
this.state === this.Landing ||
this.state === this.Crouching ||
((this.state === this.Falling || this.state === this.Peaking) && !this.timers.TimerUp('on_ground'))) {
this.body.velocity.y = PLAYER_JUMP_VEL();
this.ChangeState(this.Jumping);
events.publish('play_sound', {name: 'jump'});
}
//roll jump
else if(this.state === this.Rolling) {
this.ChangeState(this.Jumping);
this.PlayAnim('roll_jump');
//roll boost is caluclated based on how close they were to the max roll speed
this.movement.rollBoost = Math.abs(this.body.velocity.x) - PLAYER_SPEED();
this.movement.rollBoost /= (PLAYER_ROLL_SPEED() - PLAYER_SPEED());
this.movement.rollBoost *= 150;
//if they are holding away from the roll, dont go crazy
if(this.movement.rollDirection !== this.GetDirectionMultiplier()) {
this.movement.rollBoost = 0;
}
//add a little boost to their jump
this.body.velocity.y = PLAYER_JUMP_VEL() - 50;
events.publish('play_sound', {name: 'jump'});
events.publish('stop_sound', {name: 'roll'});
}
//overhead into jump atack
else if(!this.timers.TimerUp('slash_start_window') && (this.state === this.AttackOverhead || this.state === this.AttackFront)) {
this.JumpSlash();
}
//double jump
else if(!this.InAttackAnim() || this.state === this.AttackJump) {
this.DoubleJump();
}
} else if(this.body.velocity.y < 0 && !this.states.inUpdraft) {
this.body.velocity.y /= 2;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment