1 Replies - 850 Views - Last Post: 30 March 2012 - 05:29 AM Rate Topic: -----

#1 labrower17  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 29-March 12

[Java]Help w/ Text-Based Game(looping a midi file and items class atm)

Posted 29 March 2012 - 09:16 PM

Hey everyone, I am creating a text-based adventure game similar to Zork for a project in my highschool pre-AP computer science class. I am having trouble getting my midi file to loop. How would you guys suggest to loop this? I will post my code below for the audio class. Also how would you suggest to create an Items class for items such as a sword, torch, keys, lock picks, etc. I was thinking about using a multidimentional array but i'm not very familiar with these and i don't really know how to go about doing it. Thanks.

import javax.sound.midi.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class Audio{

  public void run() {
      try {
          Sequencer sequencer = MidiSystem.getSequencer();
          if (sequencer == null)
          throw new MidiUnavailableException();
          sequencer.open();
          FileInputStream is = new FileInputStream("D:/Documents/NetBeansProjects/Labyrinthian/requiemforadreamthemesong.mid");
          Sequence Seq = MidiSystem.getSequence(is);
          sequencer.setSequence(Seq);
          sequencer.start();

      } catch (Exception e) {
          e.printStackTrace();
      }
  }
}



Is This A Good Question/Topic? 0
  • +

Replies To: [Java]Help w/ Text-Based Game(looping a midi file and items class atm)

#2 labrower17  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 29-March 12

Re: [Java]Help w/ Text-Based Game(looping a midi file and items class atm)

Posted 30 March 2012 - 05:29 AM

[UPDATE]
I have gotten the midi file to loop but i still need your ideas on what i should do to create the Items class.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1