Skip to content

Instantly share code, notes, and snippets.

Created October 6, 2014 20:34
Show Gist options
  • Save anonymous/bf500baaff73e4b6cb89 to your computer and use it in GitHub Desktop.
Save anonymous/bf500baaff73e4b6cb89 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