-
Notifications
You must be signed in to change notification settings - Fork 9
Player Death Testing Plan
Player Death is an integral aspect of the game's function, and the implementation of a death screen was important to communicate to the user that the player has died and give them the option to either respawn or exit to the main menu. To improve the implementation of player death, a death animation was added. Therefore, these implementations must be adequately tested, and so PlayerDeathScreen
and the player death animation were tested in accordance with the following testing plan:
To validate that the death screen pops up once the player dies, by ensuring the death screen is displayed once the player's health reaches zero, after waiting 750ms (which allows time for the death animation to play).
Objective: To validate the death screen showing up once the player's health reaches zero.
Steps:
- Mock a GdxGame.
- Create
Player
entity, and add theCombatStatsComponent
with the default player stats. - Set player health to zero, to trigger the
PlayerDeathScreen
that shows there are three lives remaining. - Wait 4 seconds, to allow time for the death animation to play.
- Assert that the screen currently being displayed is the correct
PlayerDeathScreen
.
Objective: To validate the death screen showing up once the player's health reaches zero.
Steps:
- Mock a GdxGame.
- Create
Player
entity, and add theCombatStatsComponent
with the default player stats. - Set player health to zero, to trigger the
PlayerDeathScreen
that shows there are two lives remaining. - Wait 4 seconds, to allow time for the death animation to play.
- Assert that the screen currently being displayed is the correct
PlayerDeathScreen
.
Objective: To validate the death screen showing up once the player's health reaches zero.
Steps:
- Mock a GdxGame.
- Create
Player
entity, and add theCombatStatsComponent
with the default player stats. - Set player health to zero, to trigger the
PlayerDeathScreen
that shows there are one life remaining. - Wait 4 seconds, to allow time for the death animation to play.
- Assert that the screen currently being displayed is the correct
PlayerDeathScreen
.
Objective: To validate the death screen showing up once the player's health reaches zero.
Steps:
- Mock a GdxGame.
- Create
Player
entity, and add theCombatStatsComponent
with the default player stats. - Set player health to zero, to trigger the
PlayerDeathScreen
that shows there are zero lives remaining. - Wait 4 seconds, to allow time for the death animation to play.
- Assert that the screen currently being displayed is the correct
PlayerDeathScreen
.
@Test
void testDeathBackgroundThreeLives() {
GdxGame game = mock(GdxGame.class);
Entity player = new Entity();
player.setEntityType("player");
player.addComponent(new CombatStatsComponent(0, 10, 10, false, 3));
final Timer timer = new Timer();
java.util.TimerTask testScreen = new java.util.TimerTask() {
@Override
public void run() {
assertEquals(PLAYER_DEATH_3, game.getScreenType());
timer.cancel();
timer.purge();
}
};
timer.schedule(testScreen, 4000);
}
To validate that the death animation of the player is shown when the player's health reaches 0. Also validates the death screen showing up 750 ms later. This is to ensure:
- The death animation is displayed once the player's health reaches zero.
- The death animation is completed before the death screen pops up.
- The death of the player shows all 5 frames of the animation.
- The death screen displays the two options of either respawning or exiting to the main menu.
Since the death animation is a visual component, the best way to test its function is to provide a video of the animation. This video can also be used to test the display of the death screen. The following video provides this visual test: https://youtu.be/_UwFg-BYXFY
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files