Skip to content

Commit

Permalink
Implemented triggering of lose screen when engineer death limit reached
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Sep 11, 2023
1 parent d6868b2 commit 8945c79
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.csse3200.game.rendering.RenderService;
import com.csse3200.game.rendering.Renderer;
import com.csse3200.game.services.*;
import com.csse3200.game.ui.UIComponent;
import com.csse3200.game.ui.terminal.Terminal;
import com.csse3200.game.ui.terminal.TerminalDisplay;
import com.csse3200.game.components.maingame.MainGameExitDisplay;
Expand All @@ -59,6 +60,7 @@ public class MainGameScreen extends ScreenAdapter {
static int screenWidth = Gdx.graphics.getWidth();
static int screenHeight = Gdx.graphics.getHeight();

private Entity ui;


public static int viewportWidth = screenWidth;
Expand Down Expand Up @@ -120,6 +122,11 @@ public void render(float delta) {
physicsEngine.update();
ServiceLocator.getEntityService().update();

// Check if the game has ended
if (ServiceLocator.getGameEndService().hasGameEnded()) {
ui.getEvents().trigger("lose");
}

batch.setProjectionMatrix(camera.combined);
batch.begin();
batch.draw(backgroundTexture, 0, 0, viewportWidth, viewportHeight);
Expand Down Expand Up @@ -187,7 +194,7 @@ private void createUI() {
InputComponent inputComponent =
ServiceLocator.getInputService().getInputFactory().createForTerminal();

Entity ui = new Entity();
ui = new Entity();
ui.addComponent(new InputDecorator(stage, 10))
.addComponent(new PerformanceDisplay())
.addComponent(new MainGameActions(this.game))
Expand Down

0 comments on commit 8945c79

Please sign in to comment.