Skip to content

Player Lives

racheljadel edited this page Oct 4, 2023 · 2 revisions

Overview

Player Lives allows the player to respawn in the current level numerous times (dependent on the number of lives the player has remaining). The original number of lives given to a player is set at 3, however, an 'Extra Life' powerup, as implemented in Improved Powerups, increases player lives by 1 and therefore allows for another respawn. However, the number of lives is maxed out at 4, to not give the player too much of an advantage in the game. The number of lives is visible both in the main game and on the death screens when the player dies.

NOTE: if a player has three lives remaining, they are able to respawn two times; if a player has two lives remaining, they are able to respawn once more etc.

Dying with one life remaining forces the player to exit to the main menu and restart the game.

Design

The death screens were updated to include the number of player lives remaining, and the font was changed to Jura in order to align with the Game Design objective. An example of the new death screen image (three hearts represent three lives remaining) is seen below:

deathscreen_3_lives

The player lives stats display (three hearts represent three lives remaining) can also be seen below:

player_lives_stats_display

Key Components for Player Lives

  • DeathScreenActions and MainGameActions classes were updated to reset the number of lives to 3 when the player decides to quit the game and return to the MainMenuScreen (by clicking the Exit button).
  • PlayerDeathScreen class was updated to include the lives variable, in order for the correct player death screen to be displayed (as triggered in the initiateDeathScreen function in the MapGameArea class).
  • CombatStatsComponent class was modified to decrease the number of player lives by 1 when the player's health reaches zero (in the setHealth function).
  • PlanetScreen class was modified to set the number of lives the player has when spawned into the game to the stored variable in the GdxGame class.
  • GdxGame class was updated to include a variable lives, as well as setter and getter methods, in order for it to be accessible to all other classes and to maintain the number of player lives across different levels.
  • PlayerStatsDisplay class was updated to include the number of lives the player has left, as represented by the number of hearts remaining, and an alert if the max number of player lives (4) has been reached.
  • player.json config is updated to include the number of lives originally given to a player (3 lives).

Testing plan

Player lives has been tested in relation to the death screen, and therefore the exitsing Player Death Testing Plan has been updated in accordance with the new lives functionality.

Further, the Powerup Testing Plan has also been updated to include testing for the "extra life" powerup.

Class interaction / UML Diagrams

image To enlarge: Right click -> Open image in new tab

Clone this wiki locally