Skip to content

Player Death

racheljadel edited this page Oct 18, 2023 · 4 revisions

Overview

Player Death implements both a death screen, which shows up after the player's health reaches zero, as well as a death animation of the player's character, which is shown before the death screen pops up. The player death event is integral to the game's function, as it gives meaning to the player's health and the enemies' attacks. Once the player dies, they are given the choice to respawn or exit to the main menu screen.

Player death is closely linked to Player Lives since four death screen images must be created to accommodate for the player having either 3, 2, 1, or 0 lives remaining. Furthermore, after the player dies with zero lives remaining, they will no longer be given the option to respawn into the current game, and instead must exit to the main menu and restart.

Design

Death animation assets were sourced from a free skeleton asset pack and were selected to show the player dying by becoming a skeleton and crumbling. Since the pixel layout matches that of the player assets (16x16 pixels), it aligns with the Game Design objective.

The death screen was designed using the chosen font of Kenvector Future Thin and hearts closely resembling that of Minecraft. The two options given to the player are to either respawn in the current level or exit to the main menu (and thus restart the game).

The skeleton asset pack is seen below:

Skeleton Asset Pack

The death screen image is seen below: deathscreen_3

Key Components for Death Screen

  • DeathScreenActions class was created to implement the events of respawning the player in the MainGameScreen or exiting to the MainMenuScreen.
  • DeathScreenDisplay class was created to implement the UI of the two buttons (Respawn and Exit to Main Menu).
  • PlayerDeathScreen class was created to implement both the DeathScreenActions and the DeathScreenDisplay.
  • CombatStatsComponent was modified to trigger the change of screen display to the PlayerDeathScreen when the player's health reaches zero (in the setHealth function). This is triggered 750ms after the player's 'death', to allow time for the death animation to play.

Key Components for Death Animation

  • player.png and player.atlas image/file were modified to include the skeleton death animation ("Character_Death") and the reference to it.
  • PlayerFactory class was modified to add the animation of the "Character_Death".
  • CombatStatsComponent was modified to trigger the player's death animation when the player's health reaches zero.
  • PlayerAnimationController was modified to include an animateDeath function, which starts the "Character_Death" animation.
  • MainGameScreen was modified to include an initiateDeathScreen function, which renders the PlayerDeathScreen.

Testing plan

The death screen has been tested according to the Player Death Testing Plan.

Class interaction / UML Diagrams

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

Clone this wiki locally