FYP  1.0.0
Final Year Project -- Alexander Meuer
Hud Class Reference
Inheritance diagram for Hud:
Inheritance graph
Collaboration diagram for Hud:
Collaboration graph

Public Member Functions

void addHealthBar (std::shared_ptr< Pawn > const &pawnToTrack, sf::Vector2f const &offsetOrPosition, sf::Vector2f const &size, sf::Texture *texture=nullptr, bool stationary=false)
 Adds a healthbar to the hud. More...
 
void addLifeTracker (std::shared_ptr< int > const &livesToTrack, sf::Texture &texture, sf::Vector2f const &position, sf::Vector2f const &scale={1.f, 1.f}, sf::Vector2f const &spacing={0.f, 0.f})
 Adds a series of images to the hud. The number of images reflects the value of a shared int. More...
 
void addImage (sf::Texture &texture, sf::Vector2f const &position, sf::Vector2f const &scale={1.f, 1.f})
 Adds an image to the hud. More...
 
void addNumberTracker (std::shared_ptr< int > const &number, sf::Vector2f const &position, sf::Font const &font, unsigned int charSize=30u, sf::Vector2f const &scale={1.f, 1.f})
 Adds a number to the hud. More...
 
void update (float deltaSeconds)
 Updates all hud items.
 

Protected Member Functions

void draw (sf::RenderTarget &target, sf::RenderStates states) const override
 Draws all hud items.
 

Private Attributes

std::list< std::unique_ptr< gui::HudItem > > mItems
 Container of hud item pointers.
 

Member Function Documentation

void Hud::addHealthBar ( std::shared_ptr< Pawn > const &  pawnToTrack,
sf::Vector2f const &  offsetOrPosition,
sf::Vector2f const &  size,
sf::Texture *  texture = nullptr,
bool  stationary = false 
)

Adds a healthbar to the hud.

Parameters
pawnToTrackThe pawn whose health will be displayed by the bar.
offsetOrPositionThe offset (for following healthbars) or position (for stationary healthbars) at which to draw the bar. Offset is an offset from the pawn.
sizeThe size of the bar at full health.
textureTexture to draw the bar with. If NULL, will default to solid red.
stationaryTrue if the bar is to be non-moving. (Placed statically on the screen).
Remarks
The pawn's health at time of construction is what the healthbar will consider its max health.
void Hud::addImage ( sf::Texture &  texture,
sf::Vector2f const &  position,
sf::Vector2f const &  scale = {1.f, 1.f} 
)

Adds an image to the hud.

Parameters
textureTexture to be drawn.
positionUpper left corner of image to be drawn.
scaleAbsolute scale of the image, where {1, 1} is original texture size.
void Hud::addLifeTracker ( std::shared_ptr< int > const &  livesToTrack,
sf::Texture &  texture,
sf::Vector2f const &  position,
sf::Vector2f const &  scale = {1.f, 1.f},
sf::Vector2f const &  spacing = {0.f, 0.f} 
)

Adds a series of images to the hud. The number of images reflects the value of a shared int.

Parameters
livesToTrackShared pointer to the number of images to draw. (e.g. Lives, Deaths, Potions...)
positionThe upper left corner of the first image. This is the anchor.
scaleHow much to scale the image by. All images will be drawn the same size, this is an overall scale.
spacingThe space between each image. This is measured from the top left of the last image drawn.
void Hud::addNumberTracker ( std::shared_ptr< int > const &  number,
sf::Vector2f const &  position,
sf::Font const &  font,
unsigned int  charSize = 30u,
sf::Vector2f const &  scale = {1.f, 1.f} 
)

Adds a number to the hud.

Parameters
numberShared number to be displayed
positionLocation of number of screen (upper left corner).
fontThe font to use for the text.
charSizeThe character size of the text.
scaleHow much the scale the text by.

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