Skip to content

Instantly share code, notes, and snippets.

@aryairani
Forked from anonymous/gist:bf500baaff73e4b6cb89
Last active August 29, 2015 14:07
Show Gist options
  • Save aryairani/5e6b00b076fab6cd21f4 to your computer and use it in GitHub Desktop.
Save aryairani/5e6b00b076fab6cd21f4 to your computer and use it in GitHub Desktop.
if ((keys[KEY_JUMP] && jumptime < 0) || (jumptime < 0 && !grounded && !sliding && jumptime < 0)) {
dataPhysical.xa = jumpSpeedX;
dataPhysical.ya = -jumptime * jumpSpeedY;
jumptime++;
} else if (keys[KEY_JUMP] && mayJump && grounded) {
jumpSpeedX = 0;
jumpSpeedY = -1.9f;
jumptime = (int) JUMP_TIME;
dataPhysical.ya = jumptime * jumpSpeedY;
grounded = false;
sliding = false;
} else if (keys[KEY_JUMP] && mayJump && sliding) {
jumpSpeedX = -dataPhysical.facing * 6.0f;
jumpSpeedY = -2.0f;
jumptime = -6;
dataPhysical.xa = jumpSpeedX;
dataPhysical.ya = -jumptime * jumpSpeedY;
grounded = false;
sliding = false;
dataPhysical.facing = -dataPhysical.facing;
} else if (keys[KEY_JUMP] && jumptime > 0) {
dataPhysical.xa += jumpSpeedX;
dataPhysical.ya = jumptime * jumpSpeedY;
jumptime--;
} else if (keys[KEY_JUMP] || (jumptime < 0 && !grounded && !sliding)) {
} else {
jumptime = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment