evil-inside/src/ei/engine/sound/Sound.java

54 lines
1.1 KiB
Java
Raw Normal View History

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;
2007-03-16 19:16:00 +00:00
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);
2007-03-16 19:16:00 +00:00
this.buffer = SoundLoader.getInstnace().loadSound(ref);
}
/**
* Play this sound as a sound effect
*/
2007-03-15 23:29:55 +00:00
public void play() {
2007-03-16 19:16:00 +00:00
source = SoundLoader.getInstnace().playSound(buffer, true);
update();
2007-03-15 23:29:55 +00:00
}
/**
* Loop this sound
*/
public void loop() {
2007-03-16 19:16:00 +00:00
SoundLoader.getInstnace().playSound(buffer, true);
update();
}
public void update() {
//AL10.alSource(source.get(0), AL10.AL_POSITION, sourcePos);
2007-03-16 19:16:00 +00:00
SoundLoader.getInstnace().setSoundLocation(
source, getLocation().getX(),getLocation().getY(),0);
}
/**
* unimplamented method
*/
public void render() {}
}