Raylib Bubbles
C++11 Raylib bubble shooter game.
GameHUD Class Reference

Provides an object to manage the game HUD state. More...

#include <hud.hpp>

Classes

struct  Arrow
 The data structure used to handle the player's arrow. More...
 
struct  ArrowPiece
 Represents a texture of the bubble shooter the player controls. More...
 
struct  HeldBubble
 

Public Member Functions

 GameHUD (const PlacedBoard::BoardDims &boardDims)
 
Arrow related methods.
void updateArrowDirection (const float offsetRad)
 Updates the direction of the arrow. More...
 
void updateHUDPosition (const float offsetX, const float offsetY)
 Updates the position of the HUD. More...
 
const GameHUD::ArrowgetArrow () const
 Gives readonly access to the arrow data. More...
 
float getArrowWidth () const
 Calculates the expected width with the current arrow layout. More...
 
float getArrowHeight () const
 Calculates the expected height with the current arrow layout. More...
 
Bubble related methods.
const size_t getHeld () const
 
const std::array< HeldBubble, 5 > & getHeldBubbles () const
 
void setHeldBubble (const size_t index, const size_t hue)
 
void shiftInHeldBubbles (const size_t hue)
 
size_t heldSize () const
 

Detailed Description

Provides an object to manage the game HUD state.

This class allows managing the HUD of the game, and can be passed to GameWindow to render the HUD elements. It is a stateful object that holds the current state of the HUD, and can be updated by calling its methods, but it will not directly render anything to the screen.

Note
This class is not meant to be used directly, but rather passed to GameWindow to render the HUD.
Note
The arrow struct and instance in this class is currently hardcoded to hold exactly three pieces, as well as having its size calculated as its vertical layout (width: core, height: core + tip + spring).
Todo:
Make an enum class to hold the indexes of the arrow pieces more cleanly.
See also
GameWindow

Member Function Documentation

◆ getArrow()

const GameHUD::Arrow& GameHUD::getArrow ( ) const
inline

Gives readonly access to the arrow data.

Returns
A const reference to the arrow data.

◆ getArrowHeight()

float GameHUD::getArrowHeight ( ) const
inline

Calculates the expected height with the current arrow layout.

Returns
The height of the player arrow.

◆ getArrowWidth()

float GameHUD::getArrowWidth ( ) const
inline

Calculates the expected width with the current arrow layout.

Returns
The width of the player arrow.

◆ updateArrowDirection()

void GameHUD::updateArrowDirection ( const float  offsetRad)

Updates the direction of the arrow.

Parameters
offsetRadThe offset in radians to change the direction of the arrow by.

◆ updateHUDPosition()

void GameHUD::updateHUDPosition ( const float  offsetX,
const float  offsetY 
)

Updates the position of the HUD.

Parameters
offsetXThe x offset to change the position of the HUD by.
offsetYThe y offset to change the position of the HUD by.

The documentation for this class was generated from the following files: