Game over screen feature such as show game overscreen when player die, show total score, choose play again or back to main menu - UQdeco2800/2021-ext-studio-2 GitHub Wiki

Overview

The main part of this feature is located in

Logic section

ScoringSystem Interface

In this interface, there is only one method which is getScore(int...args) the input array is all the parameters for calculating the score. In this sprint, we only considered time in seconds.

ScoringSystemV1 class

This class implements the interface. The V1 one means we will add more things in the future sprints. For example, destroy one planes + 50 points etc. In this class, we used the Java inbuild classes Timer & TimerTask. These two allows one method (TimerTask task) be called regularly in a fixed time(1000ms in this project). We setted 1sec delay as well. The seconds, minutes are all static variables which means these values are same in this project. The startGameClock is for staring the timer. This method is called in the PlayerStatusDisplay because when the game is initialised, this class is used. The stopTimer & stopTimerTask methods are used for stop the timer. These methods are called in three ways:

  1. The first situation is when player is dead. We check if health values is less than zero in the PlayerStatusDisplay update player health value method. If true then stop the timer.

  2. Or the user presses the quit button in the game screen. We added the stop methods in MainGameActions.

  3. Or the user just closes the window. This is handled in MainGameScreen.

Display Section

ScoreDisplay and TimerDisplay basiclly are same. We implemented these two after reading through how the game engine display player's health. The most diffcult part is how to display the score in the score board. We created two tables in the score display class. We called stage.add for the board first and then the score. Then we altered some padding staff to move them in the appropriate locations.

Future implementations

In the following sprints. We might need to import more classes in the ScoringSystemV1. And use more parameters in the args array to calculate the scores.