2.0
27 Jun 2024 05:01
class PlayerWallJumpProperties {
uint Stage = 0;
bool FacingRight;
int LastSlidingTick = 0;
bool PressingJumpOneTickAgo = false;
PlayerWallJumpProperties(){}
}
array<PlayerWallJumpProperties> PlayerWallJumpPropertiesArray(jjLocalPlayerCount);
void onPlayer(jjPLAYER@ play) {
PlayerWallJumpProperties@ wallJumpProperties = @PlayerWallJumpPropertiesArray[play.localPlayerID];
const bool pressingJump = play.keyJump;
if (
pressingJump &&
!wallJumpProperties.PressingJumpOneTickAgo &&
wallJumpProperties.Stage < 2 &&
(jjGameTicks - wallJumpProperties.LastSlidingTick) < 10 //10 = number of ticks after technically letting go of the wall during which you can still start the jump. Higher numbers are more generous.
) {
wallJumpProperties.Stage = 2;
jjSample(play.xPos, play.yPos, SOUND::COMMON_JUMP);
play.ySpeed = play.jumpStrength;
play.helicopter = 0;
play.doubleJumpCount = 0;
} else if (wallJumpProperties.Stage > 1) {
if (++wallJumpProperties.Stage == 20)
wallJumpProperties.Stage = 0;
else {
play.keyRight = wallJumpProperties.FacingRight;
play.keyLeft = !wallJumpProperties.FacingRight;
play.keyJump = true;
play.helicopter = 0;
}
} else {
const auto anim = play.curAnim - jjAnimSets[play.setID];
const int xPosToTest = int(play.xPos) + (play.keyRight ? 13 : -13);
uint16 tileIDToTest;
if (
(anim == RABBIT::FALL || anim == RABBIT::HELICOPTER) &&
(play.keyRight || play.keyLeft) &&
(jjMaskedPixel(xPosToTest, int(play.yPos)-8) && jjMaskedPixel(xPosToTest, int(play.yPos)+8))
//put any additional conditions, e.g. events or tiles you can't slide on, here.
) {
play.helicopter = 0;
wallJumpProperties.Stage = 1;
wallJumpProperties.FacingRight = play.keyLeft;
play.ySpeed = 0.25; //modify as desired if you don't like this sliding speed
play.keyJump = false;
wallJumpProperties.LastSlidingTick = jjGameTicks;
} else if (wallJumpProperties.Stage == 1)
wallJumpProperties.Stage = 0;
}
wallJumpProperties.PressingJumpOneTickAgo = pressingJump;
}
void onPlayerDraw(jjPLAYERDRAW& draw) {
if (draw.sprite) {
const jjPLAYER@ play = draw.player;
if (play.isLocal && PlayerWallJumpPropertiesArray[play.localPlayerID].Stage == 1) {
const jjANIMATION@ skidding = jjAnimations[jjAnimSets[play.setID] + RABBIT::SKID1];
draw.curFrame = skidding.firstFrame + ((jjGameTicks >> 4) % skidding.frameCount);
draw.xOffset = play.direction * -7;
draw.angle = (!play.antiGrav ? 256 : -256) * play.direction;
draw.xScale = -play.direction;
}
}
}
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.