-
Notifications
You must be signed in to change notification settings - Fork 1
Features When The Player Get Attacked (Team 8)
For UI wiki page for this sprint, go here https://github.com/UQdeco2800/2022-ext-studio-1/wiki/Overall-UI-Improvement-(Team8)
The goal of this sprint is to complete the features when the player is attacked by monsters. Such as player will receiving damage and once their health is below 0 Failing the game. Moreover, this sprint also demonstrate the damage flash when player get attacked by monster.
When the player is attacked by a monster, a damage flash will appear on the screen. This indicates damage to the player visually, and will stack with multiple hits, making the screen more obscured and red. A simplistic red screen was chosen as to not over design a basic visual cue, and to allow for stacking with multiple hits. The basic red screen will inherently stack and darken as more are overlayed on the display with each hit, allowing for more simplicity in the code aswell.
Player will receiving the damage when they get attacked. And onc their health is below 0 Failing the game.
private void addActors() {
table = new Table();
table.top().left();
table.setFillParent(true);
table.padTop(45f).padLeft(5f);
// Heart image
float heartSideLength = 30f;
heartImage = new Image(ServiceLocator.getResourceService().getAsset("images/heart.png", Texture.class));
// Health text
int health = entity.getComponent(CombatStatsComponent.class).getHealth();
CharSequence healthText = String.format("Health: %d", health);
healthLabel = new Label(healthText, skin, "large");
table.add(heartImage).size(heartSideLength).pad(5);
table.add(healthLabel);
stage.addActor(table);
}
@Override
public void draw(SpriteBatch batch) {
// draw is handled by the stage
}
/**
* Updates the player's health on the ui.
* @param health player health
*/
public void updatePlayerHealthUI(int health) {
CharSequence text = String.format("Health: %d", health);
healthLabel.setText(text);
}
@Override
public void dispose() {
super.dispose();
heartImage.remove();
healthLabel.remove();
}
This feature flashes the screen red when the player is damaged in any way, with repeated loss of health stacking the effect to better communicate to players that they are being significantly hurt. It works by displaying a semi-transparent red image in a table across the entire screen, with timing handled by waitTime(). This method schedules the damage flash to dissipate after half a second (500) and can be modified to be shorter or longer with this value.
public class DamageFlashDisplayComponent extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(InventoryComponent.class);
private GdxGame game = new GdxGame();
private Table flashTable;
public DamageFlashDisplayComponent() {
super();
create();
}
@Override
public void create() {
super.create();
addActors();
}
private void addActors() {
Image damageFlash =
new Image(
ServiceLocator.getResourceService()
.getAsset("images/damageFlash.png", Texture.class));
flashTable = new Table();
flashTable.setFillParent(true);
flashTable.add(damageFlash).height(Gdx.graphics.getHeight()).width(Gdx.graphics.getWidth());
stage.addActor(flashTable);
}
public void removeDamageFlash() {
super.dispose();
flashTable.remove();
}
public void waitTime() {
new java.util.Timer().schedule(
new java.util.TimerTask() {
@Override
public void run() {
removeDamageFlash();
}
},
500
);
}
@Override
protected void draw(SpriteBatch batch) {
}
- Uniform Pixel Grid Resolution
- Storyline
- Instruction
- NPC info
- NPC Communication Script
- Inventory-System-and-Consumables
- Storyline User Test
- Traitor Clues
- Game Characters
- Player Profile User Test
- Player Eviction Menu Sprint1: User survey (Team 7)
- Player Eviction Menu Sprint2: User survey (Team 7)
- Sprint3 - Win/lose Condition: User survey (Team 7)
- Sprint4 - Polishing-tasks: User survey (Team 7)
- Transition Animation/Special Effects/Sound Effects: Feature Overviews
- Transition Animation and Effects: Design Process & Guideline
- Sprint 4 User Testing
- Transition Animation & Effect: Code Guideline-Sprint4
- Sound effect when players complete npc tasks and hover over npc cards
- Fixing the clue bug
- Music Test
- Player Eviction Menu: Design Process & Guideline
- Player Eviction Menu (Feature Overviews)
- Player Eviction Menu: Code Guideline - Sprint1
- Sprint 1 User Testing
- Detailed Eviction Card: Design Process & Guideline
- Detailed Eviction Card: Feature Overviews
- Sprint 2 User Testing
- Player Eviction Menu: Code Guideline - Sprint2
- Sprint 2 Inventory System and Consumables Items User Testing
- Sprint 2 Inventory System and Consumables Items Functionality
- NPC interaction testing plan sprint3
- NPC interaction testing results sprint3
- NPC Dialogue Scripts
- Code Guideline
- Win/lose Condition: Design Process & Guideline
- Win/lose Condition: Feature Overviews
- Sprint 3 User Testing
- Win/lose condition: Code Guideline - Sprint3
- Enemy List
- User Testing 1: Enemy Image Filter
- User Testing 2: Enemy Animation and AI
- User Testing 3: Basic Attack