Rogue: Savage Rats, a retro-themed dungeon crawler
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.
 
 
rogue-savage-rats/src/mightypork/gamecore/resources/audio/players/EffectPlayer.java

69 lines
1.4 KiB

package mightypork.gamecore.resources.audio.players;
import mightypork.gamecore.resources.audio.LazyAudio;
import mightypork.gamecore.resources.audio.Volume;
import mightypork.utils.math.constraints.vect.Vect;
/**
* Player for one-off effects
*
* @author Ondřej Hruška (MightyPork)
*/
public class EffectPlayer extends BaseAudioPlayer {
/**
* @param track audio resource
* @param basePitch base pitch (pitch multiplier)
* @param baseGain base gain (volume multiplier)
* @param volume volume control
*/
public EffectPlayer(LazyAudio track, double basePitch, double baseGain, Volume volume) {
super(track, (float) basePitch, (float) baseGain, volume);
}
/**
* Play at listener
*
* @param pitch play pitch
* @param gain play gain
* @return source id
*/
public int play(double pitch, double gain)
{
if (!hasAudio()) return -1;
return getAudio().playAsEffect(getPitch(pitch), getGain(gain), false);
}
/**
* Play at listener
*
* @param gain play gain
* @return source id
*/
public int play(double gain)
{
return play(1, gain);
}
/**
* Play at given position
*
* @param pitch play pitch
* @param gain play gain
* @param pos play position
* @return source id
*/
public int play(double pitch, double gain, Vect pos)
{
if (!hasAudio()) return -1;
return getAudio().playAsEffect(getPitch(pitch), getGain(gain), false, pos);
}
}