Skip to content

Damage buff and speed stats UI

Jas2310 edited this page Oct 16, 2024 · 6 revisions

Objective

This UI element is for items that are "Buff Items" (effect is applied immediately upon pickup). The reason that this was created was because these items do not get added to inventory, therefore making it difficult to know exactly what item did to the player, especially if it appears as a mystery box. In addition, since buff item effects are stackable (eg. an energy drink will apply an additional boost to the current speed), it is difficult for the player to keep track of the "boosts" that they have so far. Therefore, the objective of the UI element of the items is to resolve these issues, by showing the player's current stats of the buff items effects, which will update upon picking up an item. The progress bar should also set to the correct amount if the player saves and loads the game.

Implementation details of UI

Speed progress bar UI element

This progress bar, represented by an energy drink icon, shows the player's current speed boost accumulated so far. It is updated through the following...

  1. Upon creating a PlayerStatsDisplay component, a listener is created to activate the updateSpeedPercentageUI method of this class, when the "updateSpeedPercentage" event is triggered
  2. The speed progress bar is set in PlayerStatsDisplay. As such, it calls upon getSpeedProgressBarProportion of PlayerActions, to get the player's speed as a proportion of the original, base speed. This calculation finds if there is any additional speed boost that has been added to the player's speed (this may be the case if a game is saved with speed boosts, then subsequently loaded). The progress bar is then set to this value. The speed progress bar also has a set animation of 2.0f (which allows the progress bar to increase slower whenever it is updated)
  3. Upon pickup, the effect() method of the EnergyDrink class is called, which calculates the new speed (in the form of a Vector2) and the new speed boost that the character has accumulated. The new speed boost accumulated is also calculated using the getSpeedProgressBarProportion of PlayerActions, which gets the new speed as a proportion of the base speed.
  4. The event "updateSpeedPercentage" is triggered from the effect() method, passing in the new updated speed percentage and speed type of the energy drink.
  5. As explained above, the updateSpeedPercentageUI method of the PlayerStatsDisplay class is called, which sets the value of the progress bar to the new updated speed percentage

Damage buff UI element

This process is similar to the above, however, the event "updateDamageBuff" is instead triggered.

Table of Contents

Home

Design

Design Document

Design Choices

Game Wiki

Gameplay

Controls

Game Features

Utilities
Animals
Menus/screens
Character
Map
Weapon
Projectile
Items
Music/sound

User Guide

Starting the game

Game Engine

Getting Started

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

Enhancement of Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally