UQdeco2800 / 2022-ext-studio-1

MIT License
2 stars 1 forks source link

Sprint 4 - Team 4: Take players to losing screen if timer runs out #218

Open riotanabe opened 1 year ago

riotanabe commented 1 year ago

Description

Task: Take players to losing screen if timer runs out. Feature: Countdown Clock (#3 )

Players should be taken to the losing screen made by Team 3, when the countdown timer runs out which indicates the player has lost the game. Discussion should be made with team 3 to understand how we can access their methods and successfully change the screen.

Dependencies

Completion Deadline: Oct. 18

Member

riotanabe commented 1 year ago

Instructions from Team 3 on discord [13/10]:

Screen Shot 2022-10-18 at 16 42 49

Screen Shot 2022-10-18 at 16 42 36

" first you need to import the package: 'import com.deco2800.game.components.endingmenu.EndingMenuDisplay;' then call the setlose function: 'EndingMenuDisplay.setLose();' finally set the screen: 'entity.getEvents().trigger("ending");' "

riotanabe commented 1 year ago

Tried this exact method in our update method in countdownDisplay.java:

` if (this.timeRemaining <= 0) { counterLabel.setText("GAME OVER!");

        game.theGameScreen.changeStatus();
        EndingMenuDisplay.setLose();
        entity.getEvents().trigger("ending");
    }

`

But this caused the game to break when the timer runs out.

riotanabe commented 1 year ago

Solution by @jeffjeffUQ :

Screen Shot 2022-10-18 at 14 14 29

timeTime is a boolean value of whether there is time remaining or not. When timeTime is false i.e., time has run out, the "judge" variable in EndingMenuDisplay will be setLose() as per team 3's instruction, the will switch screens in to GdxGame.ScreenType.ENDING.