Display Character's Inventory - UQcsse3200/2024-studio-1 GitHub Wiki

Objective

The objective of this task is provide users a real time display of the items on GUI during gameplay. As the player picks up items during gameplay, their names will be displayed in the bottom left corner of the screen, updating and informing the player of the items they have collected and can use during the game. These items can include energy bars, health potion, or any other items designed by items team. The ultimate goal is to display the image of the item. However, as of sprint 1, items team has not implemented the images yet as such only the specifications are displayed.

Implementation Details:

Event System

To ensure the inventory display updates in real-time, an event system has been implemented

Event Listener: Monitors changes in the player's inventory and triggers an update to the UI Event Trigger: Fires whenever the player collects an item, ensuring the inventory display is refreshed and updated. Inventory Display

The inventory display is a simple UI componentt placed in the bottom left corner of the screen

UI Placement: Collected items are listed vertically, with each new item added on a new line. Item Display: Each item's name is displayed using a Label element, which is updated dynamically as the game progresses. UI Structure

Inventory Table: The items are displayed within a Table, allowing for a flexible position and easy updates. Heading: A heading "Collected:" is displayed above the items to label the inventory section. Example

An example of this on GUI as of sprint 1 is: When no item is collected:

image After collecting some items:

image Usage

Here's a basic example of how inventory display component is set up in the game:

Using LibGDX table

image Behind the Scenes

Why a Table-Based UI?

Using a Table to display the inventory provides flexibility in layout and easy management of UI elements. The table layout ensures that new items are correctly aligned and spaced, improving readability and user experience.

Further Reading

For more information on how to Table class for UI layout and dynamic updates in libGDX, refers to LibGDX Scene 2D documentation