Skip to content

Instantly share code, notes, and snippets.

Created October 6, 2014 20:07
Show Gist options
  • Save anonymous/0de6c42711d8840fb0c5 to your computer and use it in GitHub Desktop.
Save anonymous/0de6c42711d8840fb0c5 to your computer and use it in GitHub Desktop.
if ((jumptime < 0 && keys[KEY_JUMP]) || (jumptime < 0 && jumptime < 0 && !grounded && !sliding)) {
dataPhysical.xa = jumpSpeedX;
dataPhysical.ya = -jumptime * jumpSpeedY;
jumptime++;
} else if ((grounded && mayJump && keys[KEY_JUMP]) || (grounded && mayJump && jumptime < 0 && !grounded && !sliding)) {
jumpSpeedX = 0;
jumpSpeedY = -1.9f;
jumptime = (int) JUMP_TIME;
dataPhysical.ya = jumptime * jumpSpeedY;
grounded = false;
sliding = false;
} else if ((sliding && mayJump && keys[KEY_JUMP]) || (sliding && mayJump && jumptime < 0 && !grounded && !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 ((jumptime > 0 && keys[KEY_JUMP]) || (jumptime > 0 && jumptime < 0 && !grounded && !sliding)) {
dataPhysical.xa += jumpSpeedX;
dataPhysical.ya = jumptime * jumpSpeedY;
jumptime--;
} else if (keys[KEY_JUMP] || (jumptime < 0 && !grounded && !sliding)) {
// noop
} else {
jumptime = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment