예제 #1
0
 /**
  * Plays the current track.
  *
  * @param loop whether or not to loop the track
  */
 public static void play(boolean loop) {
   if (trackExists()) {
     trackEnded = false;
     if (loop) player.loop();
     else player.play();
   }
 }
예제 #2
0
 public void playTavern() {
   try {
     Random r = new Random();
     active = tavern.get(r.nextInt(tavern.size()));
     activeCat = "tavern";
     active.play();
   } catch (Exception e) {
     // TODO: handle exception
   }
 }
예제 #3
0
 public void playFight() {
   try {
     Random r = new Random();
     active = fight.get(r.nextInt(fight.size()));
     activeCat = "fight";
     active.play();
   } catch (Exception e) {
     // TODO: handle exception
   }
 }
예제 #4
0
 public void playNavTension() {
   try {
     Random r = new Random();
     active = nav_tension.get(r.nextInt(nav_tension.size()));
     activeCat = "nav_tension";
     active.play();
   } catch (Exception e) {
     // TODO: handle exception
   }
 }
예제 #5
0
 public void playNavNormal() {
   try {
     Random r = new Random();
     active = nav_normal.get(r.nextInt(nav_normal.size()));
     activeCat = "nav_normal";
     active.play();
   } catch (Exception e) {
     // TODO: handle exception
   }
 }
예제 #6
0
 /**
  * Plays the current track at the given position.
  *
  * @param position the track position (in ms)
  * @param loop whether or not to loop the track
  */
 public static void playAt(final int position, final boolean loop) {
   if (trackExists()) {
     setVolume(Options.getMusicVolume() * Options.getMasterVolume());
     trackEnded = false;
     pauseTime = 0f;
     if (loop) player.loop();
     else player.play();
     if (position >= 0) player.setPosition(position / 1000f);
   }
 }
예제 #7
0
  /** @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */
  public void init(GameContainer container) throws SlickException {
    SoundStore.get().setMaxSources(32);

    myContainer = container;
    sound = new Sound("testdata/restart.ogg");
    charlie = new Sound("testdata/cbrown01.wav");
    engine = new Sound("testdata/engine.wav");
    music = musica = new Music("testdata/SMB-X.XM");
    // music = musica = new Music("testdata/theme.ogg", true);
    musicb = new Music("testdata/kirby.ogg", true);
    burp = new Sound("testdata/burp.aif");

    music.play();
  }
예제 #8
0
  @Override
  public void enter(GameContainer container, StateBasedGame game) throws SlickException {
    super.enter(container, game);
    keyInput = new KeyInput();
    world = new World(this);
    world.init();

    // TODO: Musicクラスの利用
    music.setPosition(0);
    music.play();
    music.loop();

    // ゲーム中に動的に曲を変えたい場合
    // このBasicGameStateクラスが持つクラス
    // 今回で言えば,Battleクラスが持つWorldクラスに,
    // Battleクラスの参照を渡しておき,
    // MusicChangeメソッドなどを作成し,呼び出させるという方法がある.

    // 他にも,ShootingGameクラスなどのStateBasedGameクラスに音楽管理クラスを
    // 持たせ,そこで管理するという方法もある.
  }