Exemple #1
0
 /** Resumes the current track. */
 public static void resume() {
   if (trackExists()) {
     pauseTime = 0f;
     player.resume();
     player.setVolume(1.0f);
   }
 }
  /** @see org.newdawn.slick.BasicGame#keyPressed(int, char) */
  public void keyPressed(int key, char c) {
    if (key == Input.KEY_ESCAPE) {
      System.exit(0);
    }
    if (key == Input.KEY_SPACE) {
      sound.play();
    }
    if (key == Input.KEY_B) {
      burp.play();
    }
    if (key == Input.KEY_A) {
      sound.playAt(-1, 0, 0);
    }
    if (key == Input.KEY_L) {
      sound.playAt(1, 0, 0);
    }
    if (key == Input.KEY_RETURN) {
      charlie.play(1.0f, 1.0f);
    }
    if (key == Input.KEY_P) {
      if (music.playing()) {
        music.pause();
      } else {
        music.resume();
      }
    }
    if (key == Input.KEY_C) {
      music.stop();
      if (music == musica) {
        music = musicb;
      } else {
        music = musica;
      }

      music.loop();
    }
    if (key == Input.KEY_E) {
      if (engine.playing()) {
        engine.stop();
      } else {
        engine.loop();
      }
    }

    if (c == '+') {
      volume += 1;
      setVolume();
    }

    if (c == '-') {
      volume -= 1;
      setVolume();
    }

    if (key == Input.KEY_Y) {
      int vol = (int) (music.getVolume() * 10);
      vol--;
      if (vol < 0) vol = 0;
      // set individual volume of music
      music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_X) {
      int vol = (int) (music.getVolume() * 10);
      vol++;
      if (vol > 10) vol = 10;
      // set individual volume of music
      music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_N) {
      int vol = (int) (myContainer.getSoundVolume() * 10);
      vol--;
      if (vol < 0) vol = 0;
      // set global volume of sound fx
      myContainer.setSoundVolume(vol / 10.0f);
    }
    if (key == Input.KEY_M) {
      int vol = (int) (myContainer.getSoundVolume() * 10);
      vol++;
      if (vol > 10) vol = 10;
      // set global volume of sound fx
      myContainer.setSoundVolume(vol / 10.0f);
    }
  }