Loading Transition Screen Implementation - UQdeco2800/2022-studio-2 GitHub Wiki

High Level Description

The transitional / loading screen is a seperate GdxGame.java screen that plays an appropriate animation between levels 1 and 2 after entering the plughole.

Main Function Explanation

The implementation is split across the following files:

source/core/src/main/com/deco2800/game/screens/LevelTransitionScreen.java

source/core/src/main/com/deco2800/game/components/levelTransition/LevelTransitionDisplay.java

source/core/src/main/com/deco2800/game/components/levelTransition/LevelTransitionActions.java

source/core/src/main/com/deco2800/game/components/levelTransition/TransitionInputComponent.java

source/core/src/main/com/deco2800/game/components/player/KeyboardPlayerInputComponent.java

source/core/src/main/com/deco2800/game/screens/MainGameScreen.java

source/core/src/main/com/deco2800/game/GdxGame.java

source/core/assets/images/loadingScreen/*

All of the animation frames for the loading screen live in the above file path.

The first part of the transition screen is called in the KeyboardPlayerInputComponent.java when the player has killed the boss and is over the plug and has pressed enter. This calls a player based trigger that appears in the MainGameScreen.java, which calls the screen to be swapped to the transition screen.

As there is no support for gif animations and the transition animation frames are too large for a sprite sheet, the LevelTransitionDisplay.java file manually changes the animation frame so the animation appears correctly. It includes final variables for ease of animation playing configuration.

Once or during the level animation, the player is able to press enter in which the game will change to the next level screen.

How to view

Kill the level boss, push the plug out of the way then press enter. It will take a moment to load all the necessary .png files for the animation.

Updated UML Diagram

image

image

UML Diagram

Outdated following newer UML diagrams to reflect the Sprint 4 polishing. levelTransition

Sprint 4 Polishing

Below are the various sprint 4 code improved files related to the implementation of the Transition Screen functionality. Each section will show the SonarCloud reports at the beginning and end of the sprint.

LevelTransitionScreen.java

source/core/src/main/com/deco2800/game/screens/LevelTransitionScreen.java

image

Following the SonarCloud cleanup the new rating was:

image

The only code smell is an alert due to code duplications. These duplications are necessary to have the screen implemented and are shared between all screen implementations. This file cannot be tested for reasons identical to the LevelTransitionActions file, wherein the constructor calls functionality that is too difficult to easily mock and by extension test.

LevelTransitionDisplay.java

source/core/src/main/com/deco2800/game/components/levelTransition/LevelTransitionDisplay.java

image

Following the SonarCloud cleanup the new rating was,

image

As above in LevelTransitionScreen, the code smell is due to duplicate code that is required to be included for the screen implementations to function. Currently there is a runtime exclusive error present on the GitHub JUnit tests preventing any code coverage.

image

After a great deal of testing and exploring the inherited classes the Display tests are capable of running. While the code coverage is less than half, specific JUnit copies have been used to allow for GitHub testing while emulating a near identical imitation of the code implemented in the game. Inspection of these tests should obviously indicate this.

LevelTransitionActions.java

source/core/src/main/com/deco2800/game/components/levelTransition/LevelTransitionActions.java

image

Following the testing plan adjustments as per the SonarCloud report, the new rating is:

image

Unable to fully complete testing to ensure 100% coverage, as one function calls a set screen function, this causes a great deal of sprite rendering errors and was unable to be properly tested.

image

TransitionInputComponent.java

source/core/src/main/com/deco2800/game/components/levelTransition/TransitionInputComponent.java

image

Following SonarCloud informed adjustments, the new rating of this file is

image

Who To Talk To?

Isaac Graham, (@The Master Craig#7285, IsaacGraham128)