Move GameOver check into Level.
This commit is contained in:
parent
d64eff31e0
commit
af5bc93004
|
@ -1,7 +1,15 @@
|
|||
package de.teamteamteam.spacescooter.level;
|
||||
|
||||
import de.teamteamteam.spacescooter.screen.GameScreen;
|
||||
import de.teamteamteam.spacescooter.utility.Loader;
|
||||
|
||||
/**
|
||||
* Implementation of the actual level based gameplay logic.
|
||||
* This guy takes care of building up the basics at the very beginning,
|
||||
* spawning all the entities in the right moments, doing logic concerning whether
|
||||
* the game is over or not and other "event"-based stuff that can be configured in the
|
||||
* Levelconfig.
|
||||
*/
|
||||
public final class Level {
|
||||
|
||||
/**
|
||||
|
@ -30,4 +38,12 @@ public final class Level {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether the Game is over or not.
|
||||
* Evaluates things like whether the Player is alive or
|
||||
* - if there is a bossfight - if the boss is dead.
|
||||
*/
|
||||
public boolean isGameOver() {
|
||||
return !GameScreen.getPlayer().isAlive();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,8 +76,7 @@ public class GameScreen extends Screen {
|
|||
/**
|
||||
* Trigger level logic, trigger updates on all entities,
|
||||
* take care of user input such as pressing escape and
|
||||
* do a little(!) check on the gameover condition.
|
||||
* TODO: Let the level take care of that.
|
||||
* do a little check on the gameover condition.
|
||||
*/
|
||||
@Override
|
||||
protected void update() {
|
||||
|
@ -94,7 +93,8 @@ public class GameScreen extends Screen {
|
|||
if (Keyboard.isKeyDown(KeyEvent.VK_ESCAPE)) {
|
||||
this.setOverlay(new GamePausedScreen(this));
|
||||
}
|
||||
if (!GameScreen.player.isAlive()) { //The level shall take this over.
|
||||
//Go to GameOverScreen if the game is actually over.
|
||||
if (this.level.isGameOver()) {
|
||||
this.parent.setOverlay(new GameOverScreen(this.parent));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue