-
Notifications
You must be signed in to change notification settings - Fork 1
Pause And Resume functionality
The Pause and resume feature provides user the ability to pause the current game process (that is freezing all the entities) and continue playing after resume time in the future.
The "pause symbol" button and the pause functionality can be found in the main game area screen. The "resume" button and the resume functionality can be found in the pause menu.
The Restart feature allows players to reset the game to its initial state from the pause menu. This functionality provides a quick way for players to start over without having to exit and relaunch the game The "Restart" button can be found in the pause menu, accessible by pressing the pause button or the Esc key during gameplay. When activated, it resets all game progress and returns the player to the main game screen.
The updated render function inside MainGameScreen.java is used to call renderer.render() method based on value of the isPaused variable
public void render(float delta) {
ui.earlyUpdate();
ui.update();
if (isPaused) {
renderer.render();
return;
}
physicsEngine.update();
ServiceLocator.getEntityService().update();
ServiceLocator.getGameAreaService().update();
renderer.render();
}
Created pauseGame, unpause & saveGame function in MainGameExitDisplay.java. Assign the isPaused value based on the function being called.
public void pauseGame() {
MainGameScreen.isPaused = true;
stage.addActor(pauseTable);
table.remove();
}
public void unpause() {
MainGameScreen.isPaused = false;
pauseTable.remove();
stage.addActor(table);
}
public void saveGame() {
Array<EntityCoordinates> entities = new Array<>();
for (Entity entity : ServiceLocator.getEntityService().getEntities()) {
if (entity.getName().equals("Main Player")) {
player = entity;
SavePlayerService savePlayerService = new SavePlayerService();
savePlayerService.savePlayerState(player);
//triggers to save map data and player location, listeners in MainGameArea
player.getEvents().trigger("saveMapData");
logger.info("Saved Successfully");
}
}
}
Added listeners to pause button and they will trigger pauseGame(), unpause() & saveGame() respectively in MainGameExitDisplay.java file.
pauseBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
pauseGame();
}
});
resumeBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
unpause();
}
});
saveBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
logger.info("Save button clicked");
Label saveLabel = new Label("Game saved!", skin);
pauseTable.add(saveLabel).padTop(BTN_SPACING);
pauseTable.row();
saveGame();
}});
Added listeners to pause button and they will trigger onRestart() & onExit() in MainGameActions.java file respectively.
restartBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
unpause();
logger.debug("Restart button clicked");
entity.getEvents().trigger("restart");
}
});
exitBtn.addListener(
new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
unpause();
logger.debug("Exit button clicked");
entity.getEvents().trigger("exit");
}
});
Design Choices
Utilities
Animals
Menus/screens
Character
- Character Animations
- Character's Inventory On Display
- Character's Inventory System
- Character's HealthBar
- Character's Interaction with Items
- Character achievements
- Saving Character
- Player-(and-other-NPC)-invincibility-frames
- Player Factory
- Scoring System
- Test Plan for Inventory System
- Test Plan for Player's Interaction with Items
- Test Plan for Player's Inventory Display
- Test Plan for Saving Character State
- Test Plan for Scoring System
Map
Weapon
- Weapon Overview
- Weapon Types
- Weapon Structure
- Weapon Stats Display
- Testing Plan for Weapon Factory
- Testing Plan for Firing Controller Component
- Testing Plan for Position Tracker Component
- Testing Plan for Weapon Animation Controller component
- Testing Plan for Concrete Melee Weapon class
- Testing Plan for Concrete Ranged Weapon class