예제 #1
0
  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");
        }
      }
    }
  }