-
Notifications
You must be signed in to change notification settings - Fork 1
Winning
The 'winning' title of the feature refers to both a win condition and a win screen. In particular, the win condition of the game is a player surviving on the map for 1 minute (and thus, implementing a timer is a major component of the 'winning' feature). A countdown timer from 60 to 0 seconds is displayed on the top right of the screen under the exit button in the main game screen to let the user know the time left to win. As soon as this feat is achieved, the win condition is met and the win screen appears. On this win screen, the player is then given an opportunity to restart the game or exit to the main menu.
The coding portion of the game included creating the win screen, implementing a timer, and finally coding a condition that triggers the win screen to appear.
This design of the win screen is largely inspired by retro and indie games - utilizing a pastel, pixel art style. This was done to fit well with the retro/arcade aesthetic the game is going for. Also, this is done to complement the retro-nostalgic feel of the Thor : Ragnarok film (2017). All in all, this will be achieved by creating the main design in Photoshop and then replicating the win screen design using Java code.
Moreover, this feature will introduce several new classes: GameWinScreen GameWinActions, GameWinDisplay (linked below)
The implementation of visualising the countdown timer on the game screen can be found under
source/core/src/main/com/deco2800/game/components/maingame/MainGameExitDisplay.java
...
private Table table;
private Label timerLabel;
public boolean exitx = false;
...
...
CharSequence timerText = String.format("Timer: 60 sec");
timerLabel = new Label(timerText, skin, "large");
TextButton mainMenuBtn = new TextButton("Exit", skin);
// Triggers an event when the button is pressed.
mainMenuBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.debug("Exit button clicked");
entity.getEvents().trigger("exit");
exitx=true;
}
});
new Thread() {
public void run() {
try {
for(int i=60;i>0;i--){
timerLabel.setText("Timer :"+ i+" sec");
Thread.sleep(1000);
if(exitx == true){
break;
}
}
}
catch (InterruptedException e) {}
}
}.start();
table.add(mainMenuBtn).padTop(10f).padRight(10f);
table.row();
table.add(timerLabel).pad(20);
stage.addActor(table);
}
...
The Main Win Screen can be found under
source\core\src\main\com\deco2800\game\screens\GameWinScreen.java
public class GameWinScreen extends ScreenAdapter {
private static final Logger logger = LoggerFactory.getLogger(GameWinScreen.class);
private final GdxGame game;
private final Renderer renderer;
//private final GameWinDisplay gameWinDisplay;
private static final String[] GameWinScreenTextures = {"images/Win-screen-2-transparent.png"};
public GameWinScreen(GdxGame game) {
this.game = game;
logger.debug("drawing game win ui");
ServiceLocator.registerInputService(new InputService());
ServiceLocator.registerResourceService(new ResourceService());
ServiceLocator.registerEntityService(new EntityService());
ServiceLocator.registerRenderService(new RenderService());
renderer = RenderFactory.createRenderer();
loadAssets();
createUI();
}
...
...
private void loadAssets() {
logger.debug("Loading assets");
ResourceService resourceService = ServiceLocator.getResourceService();
resourceService.loadTextures(GameWinScreenTextures);
ServiceLocator.getResourceService().loadAll();
while (!resourceService.loadForMillis(10)) {
// This could be upgraded to a loading screen
logger.info("Loading... {}%", resourceService.getProgress());
}
}
private void unloadAssets() {
logger.debug("Unloading assets");
ResourceService resourceService = ServiceLocator.getResourceService();
resourceService.unloadAssets(GameWinScreenTextures);
}
private void createUI() {
logger.debug("Creating ui");
Stage stage = ServiceLocator.getRenderService().getStage();
Entity ui = new Entity();
ui.addComponent(new GameWinDisplay())
.addComponent(new InputDecorator(stage, 10))
.addComponent(new GameWinActions(game));
ServiceLocator.getEntityService().register(ui);
}
...
The logic behind the Win screen can be found under
source\core\src\main\com\deco2800\game\components\gamearea\GameWinActions.java
public class GameWinActions extends Component {
private static final Logger logger = LoggerFactory.getLogger(GameWinActions.class);
private final GdxGame game;
public GameWinActions(GdxGame game) {
this.game = game;
}
@Override
public void create() {
entity.getEvents().addListener("replay", this::onReplay);
entity.getEvents().addListener("exit", this::onExit);
}
/**
* Swaps to the Main Menu screen.
*/
private void onExit() {
logger.info("Exiting main game screen");
//game.setScreen(GdxGame.ScreenType.MAIN_MENU);
game.setScreen(MAIN_MENU);
}
/**
* Swaps to the Main Game Screen when the character dies.
*/
private void onReplay() {
logger.info("Restart Game");
//game.setScreen(GdxGame.ScreenType.MAIN_GAME);
game.setScreen(MAIN_GAME);
}
}
The logic behind displaying the Win screen can be found under
source\core\src\main\com\deco2800\game\components\gamearea\GameWinDisplay.java
private void createGameWin() {
table = new Table();
table.setFillParent(true);
//Label gameWinLable = new Label("YOU WIN",skin);
//Label gameWinTextLable = new Label("You have survived the horders of terror on " +
// "the Bifrost. Theevil hela awaits you.",skin);
Image title =
new Image(
ServiceLocator.getResourceService()
.getAsset("images/Win-screen-2-transparent.png", Texture.class));
TextButton replayButton = new TextButton("Replay", skin);
TextButton exitButton = new TextButton("Exit", skin);
replayButton.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.info("replay game button clicked");
entity.getEvents().trigger("replay");
}
});
exitButton.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.info("exit button clicked");
entity.getEvents().trigger("exit");
}
});
table.add(title).top();
table.row();
//table.add(replayButton).padTop(-30f);
table.add(replayButton).padTop(30f);
table.row();
table.add(exitButton).padTop(15f);
//table.setTransform(false);
stage.addActor(table);
}
...
The main goal of the testing we are undertaking is to gather outside feedback on our variety of win screen designs. Outside feedback will be extremely helpful - providing us with unique and unbiased perspectives on our design. The feedback we receive will then be taken into consideration when finalizing the win screen design, hopefully allowing us to create something that people appreciate.
In the Design User Testing participants will be shown a variety of win screen designs. They will also be briefly interviewed, as to gather information (e.g. likes, dislikes and suggestions). Specifically, we aim for each member in Team 6 to interview at least 2 people and take some notes. The results will then be analysed and taken into consideration as a group.
- What did you like about the designs? (Why?)
- What did you like dislike about the designs? (Why?)
- Any favourites? (Why?)
- Any suggestions?
Notes taken during one of the interviews
The feedback we received for the designs was largely positive. In particular, many people enjoyed the colourful nature of the game/win screen, with participants often complimenting the 'purple' aesthetic. However, many of the participants had constructive criticism regarding the non-purple colour variations and the basic font used in the original designs. Particularly they felt that the non-purple colour variations didn't flow well with the rest of the game. In regards to the font, some thought it was 'too basic' and was 'too boring for the grand sci-fi theme'.
Using this feedback, we decided to maintain visual consistency by utilizing purple hues similar to that of the Bifrost. Additionally, we tried out various other fonts to add visual flair. Eventually, we decided on a blocky pixel-style font to match that of Team 6's Death Screen.
- Writing Unit tests for our Bridge and Lane class, and optimizing the code based upon the unit testing.
- Have a look into the @sonarcloud and try to fix as many code smells and bugs as possible.
Documentation - Coding the Win Screen/Win Condition