Skip to content

Companion Modified Lab Window

gaurikadiwan edited this page Oct 5, 2023 · 2 revisions

Overview

Lab Window Class is specifically designed to be used within the game's laboratory or user interface.It displays a background texture representing the laboratory, setting the visual context for laboratory-related interactions.The lab window contains a set of user interface elements (buttons) that enable interactions. One of the central features of the LabWindow is the ability for players to select power-ups.

Constructors

LabWindow(Texture background) Creates an instance of LabWindow with the specified background texture.

Parameters

  • background (Texture): The background texture for the laboratory window.

Methods

MakeNewLaboratory() Static factory method to create a new LabWindow instance with a default laboratory background.

  • Returns:
    • LabWindow: A new LabWindow instance.

remove() Call this method to exit the Laboratory. It also unregisters the input override component.

  • Returns:
    • boolean: true if the window was successfully removed; otherwise, false.

Input Override

The LabWindow utilises an InputOverrideComponent to intercept and override user input while the lab window is active.

User Interface Elements

The LabWindow class contains user interface elements for interacting with laboratory-related actions.

Potion Selection Buttons

The laboratory window provides buttons for selecting different power-ups. These buttons allow the player to choose from various power-up options, each represented by an image and labeled with its name.

  • Power-Up Buttons:
    • "Death"
    • "Speed"
    • "Health"
    • "Invincibility"
    • "2x Damage"
    • "Extra Life"
    • "Snap"
    • "Double Cross"

When a button is clicked, the associated power-up is spawned in the game, and the laboratory window is closed.

Exit Button The "EXIT" button allows the player to exit the laboratory and return to the main game. Clicking this button closes the laboratory window.

Usage

Create a new Laboratory window with a custom background texture

Texture customBackground = new Texture("custom/lab_background.png");

LabWindow labWindow = new LabWindow(customBackground);

Add the laboratory window to the game stage

stage.addActor(labWindow);

To remove the laboratory window and exit the laboratory

labWindow.remove();

UML Diagram

WhatsApp Image 2023-10-05 at 9 26 38 AM

Testing Plan

LabWindowTest is the test class for the modified LabWindow.

Clone this wiki locally