This commit is contained in:
ramapcsx2 2014-11-30 15:56:08 +01:00
commit 148c9ca491
3 changed files with 21 additions and 11 deletions

View File

@ -1,5 +1,5 @@
name:Lustiger Levelname
backgroundMusic:music/bla.wav
name:Testlevel \o/
backgroundMusic:music/ScooterFriendsTurbo8Bit.wav
background:StarBackground
-
[0-4]

View File

@ -9,6 +9,7 @@ import de.teamteamteam.spacescooter.entity.enemy.EnemyOne;
import de.teamteamteam.spacescooter.entity.enemy.EnemyThree;
import de.teamteamteam.spacescooter.entity.enemy.EnemyTwo;
import de.teamteamteam.spacescooter.screen.GameScreen;
import de.teamteamteam.spacescooter.sound.SoundSystem;
import de.teamteamteam.spacescooter.utility.Loader;
import de.teamteamteam.spacescooter.utility.Random;
@ -32,6 +33,11 @@ public final class Level {
*/
private int levelClock;
/**
* Thread handle for the backgroundMusic being played.
*/
private Thread backgroundMusic;
/**
* Constructor creating a LevelConfig based on a given config file.
@ -48,6 +54,7 @@ public final class Level {
public void doBuildUp() {
this.spawnEntityByAvailableName(Entity.availableNames.valueOf(this.config.background), 0, 50);
GameScreen.setPlayer(new Player(200, 300));
this.backgroundMusic = SoundSystem.playSound(this.config.backgroundMusic);
}
/**
@ -129,4 +136,15 @@ public final class Level {
break;
}
}
/**
* Clean up before the Level is torn down.
* Stop the music, ...
*/
public void tearDown() {
if(this.backgroundMusic != null) {
this.backgroundMusic.interrupt();
this.backgroundMusic = null;
}
}
}

View File

@ -10,7 +10,6 @@ import de.teamteamteam.spacescooter.gui.InterfaceBar;
import de.teamteamteam.spacescooter.gui.ScoreBar;
import de.teamteamteam.spacescooter.gui.ShieldBar;
import de.teamteamteam.spacescooter.level.Level;
import de.teamteamteam.spacescooter.sound.SoundSystem;
import de.teamteamteam.spacescooter.utility.CollisionHandler;
/**
@ -33,11 +32,6 @@ public class GameScreen extends Screen {
*/
private long gameClockTrigger;
/**
* Internal Thread handle for the background music.
*/
private Thread backgroundMusic;
/**
* GameScreen Constructor.
* Takes the level as its second parameter.
@ -54,8 +48,6 @@ public class GameScreen extends Screen {
new HealthBar(10, 5);
new ShieldBar(10, 27);
new ScoreBar(575, 33);
this.backgroundMusic = SoundSystem.playSound("music/ScooterFriendsTurbo8Bit.wav");
}
@ -106,7 +98,7 @@ public class GameScreen extends Screen {
*/
@Override
public void cleanup() {
this.backgroundMusic.interrupt();
this.level.tearDown();
super.cleanup();
}