Add ambience
This commit is contained in:
@@ -24,6 +24,8 @@ public class AcousticHandler {
|
||||
private GameMusic scheduled = null; // Scheduled track to play next
|
||||
private GameMusic old = null; // Old track being faded out
|
||||
|
||||
private GameMusic birds;
|
||||
|
||||
private float mainVolume = 0.0f;
|
||||
private float musicVolume = 1.0f;
|
||||
private float soundVolume = 1.0f;
|
||||
@@ -38,6 +40,8 @@ public AcousticHandler(MdgaApp app) {
|
||||
mainVolume = prefs.getFloat("mainVolume", 1.0f);
|
||||
musicVolume = prefs.getFloat("musicVolume", 1.0f);
|
||||
soundVolume = prefs.getFloat("soundVolume", 1.0f);
|
||||
|
||||
birds = new GameMusic(app, MusicAsset.BIRDS, getSoundVolumeTotal(), MusicAsset.BIRDS.getSubVolume(), MusicAsset.BIRDS.getLoop(), 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,6 +64,8 @@ public void update() {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
birds.update(Math.min(getSoundVolumeTotal(), getMusicVolumeTotal() > 0 ? 0 : 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,6 +159,8 @@ public void playState(MdgaState state) {
|
||||
}
|
||||
MusicAsset asset = null;
|
||||
|
||||
birds.pause();
|
||||
|
||||
switch (state) {
|
||||
case MAIN:
|
||||
playGame = false;
|
||||
@@ -163,6 +171,7 @@ public void playState(MdgaState state) {
|
||||
asset = MusicAsset.LOBBY;
|
||||
break;
|
||||
case GAME:
|
||||
birds.play();
|
||||
addGameTracks();
|
||||
playGame = true;
|
||||
assert (!gameTracks.isEmpty()) : "no more game music available";
|
||||
|
||||
@@ -15,7 +15,8 @@ enum MusicAsset {
|
||||
GAME_3("TheSynthRave.wav", 1.0f),
|
||||
GAME_4("LaserParty.wav", 1.0f),
|
||||
GAME_5("RetroNoir.wav", 1.0f),
|
||||
GAME_6("SpaceInvaders.wav", 1.0f);
|
||||
GAME_6("SpaceInvaders.wav", 1.0f),
|
||||
BIRDS("nature-ambience.ogg", true, 1.0f);
|
||||
|
||||
private final String path;
|
||||
private final boolean loop;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user