Versatile Java game engine with pluggable backends (this was used in Rogue, I think)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gamecore/src/mightypork/gamecore/audio/players/EffectPlayer.java

77 lines
1.2 KiB

package mightypork.gamecore.audio.players;
import mightypork.gamecore.audio.IAudio;
import mightypork.gamecore.audio.Volume;
import mightypork.utils.math.constraints.vect.Vect;
/**
* Player for one-off effects
*
* @author Ondřej Hruška (MightyPork)
*/
public class EffectPlayer extends AudioPlayer {
/**
* @param track audio resource
* @param volume volume control
*/
public EffectPlayer(IAudio track, Volume volume)
{
super(track, volume);
}
/**
* Play at listener
*
* @param gain play gain
* @param pitch play pitch
*/
public void play(double gain, double pitch)
{
if (!hasAudio()) return;
getAudio().play(computeGain(gain), computePitch(pitch), false);
}
/**
* Play at listener
*
* @param gain play gain
*/
public void play(double gain)
{
play(gain, 1);
}
/**
* Play at given position
*
* @param gain play gain
* @param pos play position
*/
public void play(double gain, Vect pos)
{
play(gain, 1, pos);
}
/**
* Play at given position
*
* @param gain play gain
* @param pitch play pitch
* @param pos play position
*/
public void play(double gain, double pitch, Vect pos)
{
if (!hasAudio()) return;
getAudio().play(computeGain(gain), computePitch(pitch), false, pos);
}
}