Artifact : Sliders

The artifact that I will go through this week will be the Sliders.

What is the Slider ?

The sliders I’ve created can be used either as a Health bars or Volume controllers or in any scenario where you have a bar that needs to get re sized often and without effort.
The slider is  a rectangle that grows from 0 being the lowest all the way up to 100 being a full bar, easily set by an integer.

SliderGui

How was the Slider created?

The way i created was by the use of two rectangles that are placed on top of each other. The idea here is that one of them will be re sized to represent the value between 1-100 and the other rectangle will be used to highlight the bar on certain events like Low HP or by Mouse Hovering over it. Depends on where the specific slider is being used.

Functions that the slider have are the following:

SetSlider(int p_X, int p_Y, int p_Width, int p_Height);
In order to create a slider it requires to have an X and Y Position of where its supposed to be drawn on the screen.

SetPosition(int p_x, int p_y);
In order to change the position of the slider as the game progresses, As our GUI needs to be in the same place, even as the camera moves. The position is set based on the players position
SetValue(int value);
The Set Value sets the value on how much of the slider that should be drawn, 0 being nothing 100 being a full bar.

GetValue();
Returns the Value of the bar, could be used for calculations

MouseDown(int x, int y);
Sets a bool to true if mouse down occurs on the slider

MouseUp();
Reverts the bool back to false

MoveMouse(int x, int y);
If the bool is true change the value of the slider, depending on what direction it is moved, or just simply highlighting the bar upon mouse hovering

Why was the Slider needed?

The slider is needed in order to create a simple tool for creating sliders that can be used in multiple ways. The mouse functions are for example not needed for a health bar, while the mouse function would prove very useful while having a volume slider.

At this moment the slider is being used as a Health bar, and Energy Bar inside our GUI. but in the future whenever needed, creating sliders for volume control or similar will be quick and easy.