private void mainLoop() {
if (jumping) {
jumpTime++;
if (inAir)
return;
inAir = true;
canJump = false;
// need to set airspeed depending on jump time here
airSpeed -= jumpHeight;
}
}
}
// ====== Jumping ======
private boolean jumping = false;
private static final float MAX_JUMP_HEIGHT = 8.0f * SCALE;
private static final float MIN_JUMP_HEIGHT = 4.0f * SCALE;
private float jumpHeight = MIN_JUMP_HEIGHT;
private float jumpTime = 0.0f;
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
player.setJumping(true);
player.setJumpTime(0);
}
}
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
player.setJumping(false);
player.setCanJump(true);
}
}
private void mainLoop() {
if (jumping) {
jumpTime++;
if (inAir)
return;
inAir = true;
canJump = false;
// need to set airspeed depending on jump time here
airSpeed -= jumpHeight;
}
}
}
// ====== Jumping ======
private boolean jumping = false;
private static final float MAX_JUMP_HEIGHT = 8.0f * SCALE;
private static final float MIN_JUMP_HEIGHT = 4.0f * SCALE;
private float jumpHeight = MIN_JUMP_HEIGHT;
private float jumpTime = 0.0f;
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
player.setJumping(true);
player.setJumpTime(0);
}
}
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
player.setJumping(false);
player.setCanJump(true);
}
}