package ei.engine.sound; import ei.engine.scene.Entity; /** * A sound that can be played through OpenAL * * @author Kevin Glass */ public class Sound extends Entity{ /** The buffer containing the sound */ private int buffer; private int source; /** * Create a new sound * * @param name The name of the sound * @param ref the path to the sound file */ public Sound(String name, String ref) { super(name); this.buffer = SoundLoader.getInstnace().loadSound(ref); } /** * Play this sound as a sound effect */ public void play() { source = SoundLoader.getInstnace().playSound(buffer, true); update(); } /** * Loop this sound */ public void loop() { SoundLoader.getInstnace().playSound(buffer, true); update(); } public void update() { //AL10.alSource(source.get(0), AL10.AL_POSITION, sourcePos); SoundLoader.getInstnace().setSoundLocation( source, getLocation().getX(),getLocation().getY(),0); } /** * unimplamented method */ public void render() {} }