public void tick(int dt) { if (plyr.transitioning > -1) return; ticker += dt / 1000f; if (ticker > 1) ticker = 0; if (open == true) { if (y <= 0) { y = 0; return; } else { y -= (500 / 1000f) * dt; float f = 1 - ((((float) closedy - (float) y) / (float) closedy) * .5f); sound.changeVolume(f); } } else { if (y >= closedy) { y = closedy; return; } else { y += (1000 / 1000f) * dt; float f = 1 - ((((float) closedy - (float) y) / (float) closedy) * .5f); sound.changeVolume(f); } } if (y <= 0) y = 0; if (y >= closedy) y = closedy; this.transitioning = (open == true && y > 0) || (open == false && y < closedy) || open; }
public void keyPressed(int key, char c) { if (key == Input.KEY_Q) { if (!(y == 0 || y == closedy)) return; open = !open; if (open == true) { ticker = 0; sound.playSound("la_inv-open.wav"); // sound.changeVolume(.5f); } else { sound.playSound("la_inv-close.wav"); input.clearKeyPressedRecord(); // sound.changeVolume(1f); } } if (open == true) { if (y <= 0) { for (int i = 0; i < 4; i++) { if (key == Main.keys[i]) { this.selection += Main.vectors[0][i]; this.selection += Main.vectors[1][i] * 2; sound.playSound("la_invmove.wav"); ticker = 0; break; } } if (this.selection > 9) this.selection = 0; else if (this.selection < 0) this.selection = 9; if (key == Input.KEY_S) { Weapon tempweap = plyr.weapons[0]; plyr.weapons[0] = plyr.inventory[this.selection]; plyr.inventory[this.selection] = tempweap; sound.playSound("la_invselect.wav"); } if (key == Input.KEY_D) { Weapon tempweap = plyr.weapons[1]; plyr.weapons[1] = plyr.inventory[this.selection]; plyr.inventory[this.selection] = tempweap; sound.playSound("la_invselect.wav"); } } } }