Skip to content

Features When The Player Get Attacked (Team 8)

Ty Briggs edited this page Oct 20, 2022 · 8 revisions

Features When The Player Get Attacked

For UI wiki page for this sprint, go here https://github.com/UQdeco2800/2022-ext-studio-1/wiki/Overall-UI-Improvement-(Team8)

Goal

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.

Design

Damage Flash

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.

damageFlash

Functionality

Game Over Screen

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();
  }

Damage Flash

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) {
    }

Table of Contents

Home

Game Design

User survey

Sprint 4

Eviction Menu and Win/lose Logic: Polishing tasks (Team 7)

Button Sounds and Ending Menu improve (Team 3)

Sound effect and Fixing the clue bug (Team 6)

Improvement of Enemy and Attack (Team 1)

Add Features When The Player Get Attacked and Overall UI Improvement (Team 8)

Sprint 1

Achievement System (Team 2)

Player Eviction Menu (Team 7)

Countdown Clock (Team 4)

Music (Team3)

Map (Team6)

Sprint 2

Player Eviction Menu (Team 7)

Character Design & Animation (Team 1)

Music (Team 3)

Inventory System and Consumables Items (Team 8)

Scenario design

Achievement System(team 2)

Storyline (Team 5)

Countdown Clock (Team 4)

Sprint 3

Ending Menu (Team 3)

NPC interaction (Team 2)

Win/lose Condition (Based on Eviction Menu) (Team 7)

Player Profile (Team 4)

Game Logo (Team 8)

Clue storage (Team 6)

Enemy Design and Attack (Team 1)

Scenario design for village(Team5)

Game design
Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally