Example #1
0
  public void keyPressed(int key, char c) {
    switch (key) {
      case Input.KEY_ENTER:
        bienvenue.stop();
        if (selected == 1) {
          try {
            game.getState(3).init(container, game);
          } catch (SlickException e) {
            e.printStackTrace();
          }
          game.enterState(3);
        } else if (selected == 2) {
          try {
            game.getState(7).init(container, game);
          } catch (SlickException e) {
            e.printStackTrace();
          }
          game.enterState(7);

        } else if (selected == 3) {
          container.exit();
        }
        break;
      case Input.KEY_K:
      case Input.KEY_UP:
        if (this.selected > 1) {
          --this.selected;
        } else this.selected = 3;
        playSound();
        break;
      case Input.KEY_J:
      case Input.KEY_DOWN:
        if (this.selected < 3) {
          ++this.selected;
        } else this.selected = 1;
        playSound();
        break;
      case Input.KEY_F1:
        bienvenue.stop();
        bienvenue.play();
        break;

      case Input.KEY_ESCAPE:
        container.exit();
        break;
    }
  }
Example #2
0
 public void playSound() {
   jouer.stop();
   score.stop();
   quitter.stop();
   if (!bienvenue.playing()) {
     switch (selected) {
       case 1:
         jouer.play();
         break;
       case 2:
         score.play();
         break;
       case 3:
         quitter.play();
         break;
     }
   }
 }
Example #3
0
 void stop() {
   SoundStore.get().clear();
   InternalTextureLoader.get().clear();
   if (partido.fueGrabado()) {
     if (JOptionPane.showConfirmDialog(
             principal, "Desea guardar el partido?", "Guardar Partido", JOptionPane.YES_NO_OPTION)
         == 0) {
       if (jfc.showSaveDialog(principal) == JFileChooser.APPROVE_OPTION) {
         try {
           partido.getPartidoGuardado().save(jfc.getSelectedFile());
           if (principal != null) {
             principal.addGuardadoLocal(new File[] {jfc.getSelectedFile()});
           }
         } catch (Exception ex) {
           logger.error("Error al guardar partido", ex);
         }
       }
     }
   }
   if (sonidos) {
     for (Sound s : ambiente) {
       s.stop();
     }
     gol.stop();
     remate[0].stop();
     remate[1].stop();
     poste[0].stop();
     poste[1].stop();
     ovacion[0].stop();
     ovacion[1].stop();
     rebote.stop();
     silbato.stop();
   }
   if (principal != null) {
     principal.setVisible(true);
     principal.requestFocus();
   } else {
     System.exit(0);
   }
 }
Example #4
0
 @Override
 public void stop() {
   super.stop();
   instanceCounter.clear();
 }
Example #5
0
  /** @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);
    }
  }
Example #6
0
 /** Turn off the sound. Calls Sound.stop() on the sfx and music. */
 public void muteSound() {
   // Yes, stop the sound entirely, not just mute it.
   sfx.stop();
   music.stop();
 }