changed Vector2D to Vector2f insted and added sound but the sound is not finnishd yet.
and added a update method to entity for ex the sound entity to update its position in the world. Added loging support to whit MultiPrintStream.java
This commit is contained in:
parent
b2cf5d543b
commit
9d4810d38e
37 changed files with 1262 additions and 39 deletions
53
src/ei/engine/sound/Sound.java
Normal file
53
src/ei/engine/sound/Sound.java
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package ei.engine.sound;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.openal.AL10;
|
||||
|
||||
import ei.engine.scene.Entity;
|
||||
import ei.engine.util.MultiPrintStream;
|
||||
|
||||
/**
|
||||
* A sound that can be played through OpenAL
|
||||
*
|
||||
* @author Kevin Glass
|
||||
*/
|
||||
public class Sound extends Entity{
|
||||
/** The buffer containing the sound */
|
||||
private int buffer;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
try {
|
||||
this.buffer = SoundLoader.getInstnace().loadSound(ref);
|
||||
} catch (IOException e) {
|
||||
MultiPrintStream.out.println("Unable to load sound: "+ref+" - "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Play this sound as a sound effect
|
||||
*
|
||||
* @param pitch The pitch of the play back
|
||||
* @param gain The gain of the play back
|
||||
*/
|
||||
public void play(float pitch, float gain) {
|
||||
SoundLoader.getInstnace().playSound(buffer, pitch, gain, getLocation());
|
||||
}
|
||||
|
||||
public void update() {
|
||||
//AL10.alSource(source.get(0), AL10.AL_POSITION, sourcePos);
|
||||
}
|
||||
|
||||
/**
|
||||
* unimplamented method
|
||||
*/
|
||||
public void render() {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue