r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
gme::HUDSystem Class Referencefinal

System responsible for rendering and updating the game's Heads-Up Display. More...

#include <HUD.hpp>

+ Inheritance diagram for gme::HUDSystem:
+ Collaboration diagram for gme::HUDSystem:

Public Member Functions

 HUDSystem (const std::shared_ptr< eng::IRenderer > &renderer, ecs::Registry &registry)
 Constructor - initializes the HUD system and creates initial UI elements.
 
 ~HUDSystem () override=default
 Destructor.
 
 HUDSystem (const HUDSystem &)=delete
 Deleted copy constructor (non-copyable)
 
HUDSystemoperator= (const HUDSystem &)=delete
 Deleted copy assignment operator (non-copyable)
 
 HUDSystem (HUDSystem &&)=delete
 Deleted move constructor (non-movable)
 
HUDSystemoperator= (HUDSystem &&)=delete
 Deleted move assignment operator (non-movable)
 
void update (ecs::Registry &registry, float) override
 Update the HUD system (called each frame)
 
 HUDSystem (const std::shared_ptr< eng::IRenderer > &renderer, ecs::Registry &registry)
 
 ~HUDSystem () override=default
 
 HUDSystem (const HUDSystem &)=delete
 
HUDSystemoperator= (const HUDSystem &)=delete
 
 HUDSystem (HUDSystem &&)=delete
 
HUDSystemoperator= (HUDSystem &&)=delete
 
void update (ecs::Registry &registry, float) override
 
- Public Member Functions inherited from ecs::ASystem
bool isEnable () override
 
void setEnable (const bool enable) override
 
- Public Member Functions inherited from ecs::ISystem
virtual ~ISystem ()=default
 

Private Member Functions

void createScoreHUD (ecs::Registry &registry, float x, float y)
 Create the score display HUD elements.
 
void updateScore (ecs::Registry &registry, int newScore) const
 Update the displayed score value.
 
void createScoreHUD (ecs::Registry &registry, float x, float y)
 
void updateScore (ecs::Registry &registry, int newScore) const
 

Private Attributes

const std::shared_ptr< eng::IRenderer > & m_renderer
 Renderer for drawing HUD elements.
 
ecs::Registrym_registry
 ECS registry reference.
 
ecs::Entity m_scoreBgEntity {}
 Entity for score background sprite.
 
std::vector< ecs::Entitym_scoreDigitEntities
 Entities for individual score digits.
 

Detailed Description

System responsible for rendering and updating the game's Heads-Up Display.

This ECS system manages all HUD elements including:

  • Score display with digit sprites
  • Background elements for UI components
  • Real-time score updates

The HUD is created at initialization and updated each frame to reflect the current game state. It uses sprite-based rendering for visual elements.

Definition at line 16 of file HUD.hpp.

Constructor & Destructor Documentation

◆ HUDSystem() [1/6]

gme::HUDSystem::HUDSystem ( const std::shared_ptr< eng::IRenderer > & renderer,
ecs::Registry & registry )
inlineexplicit

Constructor - initializes the HUD system and creates initial UI elements.

Parameters
rendererShared pointer to the renderer for drawing UI elements
registryReference to the ECS registry for entity management

Automatically creates the score HUD at position (10, 10) upon construction

Definition at line 43 of file HUD.hpp.

References createScoreHUD(), and m_registry.

+ Here is the call graph for this function:

◆ ~HUDSystem() [1/2]

gme::HUDSystem::~HUDSystem ( )
overridedefault

Destructor.

◆ HUDSystem() [2/6]

gme::HUDSystem::HUDSystem ( const HUDSystem & )
delete

Deleted copy constructor (non-copyable)

◆ HUDSystem() [3/6]

gme::HUDSystem::HUDSystem ( HUDSystem && )
delete

Deleted move constructor (non-movable)

◆ HUDSystem() [4/6]

gme::HUDSystem::HUDSystem ( const std::shared_ptr< eng::IRenderer > & renderer,
ecs::Registry & registry )
inlineexplicit

Definition at line 19 of file HUD.hpp.

References createScoreHUD(), and m_registry.

+ Here is the call graph for this function:

◆ ~HUDSystem() [2/2]

gme::HUDSystem::~HUDSystem ( )
overridedefault

◆ HUDSystem() [5/6]

gme::HUDSystem::HUDSystem ( const HUDSystem & )
delete

◆ HUDSystem() [6/6]

gme::HUDSystem::HUDSystem ( HUDSystem && )
delete

Member Function Documentation

◆ createScoreHUD() [1/2]

void gme::HUDSystem::createScoreHUD ( ecs::Registry & registry,
float x,
float y )
private

Create the score display HUD elements.

Parameters
registryECS registry for creating entities
xX-coordinate for the score display position
yY-coordinate for the score display position

Creates background and digit entities for the score display. Initializes the visual representation of the player's score.

Definition at line 7 of file HUD.cpp.

References ecs::Registry::createEntity(), m_scoreBgEntity, m_scoreDigitEntities, utl::Path::Texture::TEXTURE_SCORE_COUNTER_BG, utl::Path::Texture::TEXTURE_SCORE_DIGIT_0, and ecs::Registry::EntityBuilder::with().

Referenced by HUDSystem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createScoreHUD() [2/2]

void gme::HUDSystem::createScoreHUD ( ecs::Registry & registry,
float x,
float y )
private

◆ operator=() [1/4]

HUDSystem & gme::HUDSystem::operator= ( const HUDSystem & )
delete

Deleted copy assignment operator (non-copyable)

◆ operator=() [2/4]

HUDSystem & gme::HUDSystem::operator= ( const HUDSystem & )
delete

◆ operator=() [3/4]

HUDSystem & gme::HUDSystem::operator= ( HUDSystem && )
delete

Deleted move assignment operator (non-movable)

◆ operator=() [4/4]

HUDSystem & gme::HUDSystem::operator= ( HUDSystem && )
delete

◆ update() [1/2]

void gme::HUDSystem::update ( ecs::Registry & registry,
float  )
overridevirtual

Update the HUD system (called each frame)

Parameters
registryECS registry containing all entities and components
dtDelta time (unused in current implementation)

Updates score display and other HUD elements based on current game state

Implements ecs::ISystem.

Definition at line 64 of file HUD.cpp.

References ecs::Registry::getAll().

+ Here is the call graph for this function:

◆ update() [2/2]

void gme::HUDSystem::update ( ecs::Registry & registry,
float  )
overridevirtual

Implements ecs::ISystem.

◆ updateScore() [1/2]

void gme::HUDSystem::updateScore ( ecs::Registry & registry,
int newScore ) const
private

Update the displayed score value.

Parameters
registryECS registry containing score entities
newScoreNew score value to display

Updates the sprite indices of digit entities to reflect the new score. Handles score formatting and digit separation.

Definition at line 29 of file HUD.cpp.

References ecs::Registry::getComponent(), utl::Path::Texture::TEXTURE_SCORE_DIGIT_0, utl::Path::Texture::TEXTURE_SCORE_DIGIT_1, utl::Path::Texture::TEXTURE_SCORE_DIGIT_2, utl::Path::Texture::TEXTURE_SCORE_DIGIT_3, utl::Path::Texture::TEXTURE_SCORE_DIGIT_4, utl::Path::Texture::TEXTURE_SCORE_DIGIT_5, utl::Path::Texture::TEXTURE_SCORE_DIGIT_6, utl::Path::Texture::TEXTURE_SCORE_DIGIT_7, utl::Path::Texture::TEXTURE_SCORE_DIGIT_8, utl::Path::Texture::TEXTURE_SCORE_DIGIT_9, and ecs::Transform::x.

+ Here is the call graph for this function:

◆ updateScore() [2/2]

void gme::HUDSystem::updateScore ( ecs::Registry & registry,
int newScore ) const
private

Member Data Documentation

◆ m_registry

ecs::Registry & gme::HUDSystem::m_registry
private

ECS registry reference.

Definition at line 103 of file HUD.hpp.

Referenced by HUDSystem().

◆ m_renderer

const std::shared_ptr< eng::IRenderer > & gme::HUDSystem::m_renderer
private

Renderer for drawing HUD elements.

Definition at line 102 of file HUD.hpp.

◆ m_scoreBgEntity

ecs::Entity gme::HUDSystem::m_scoreBgEntity {}
private

Entity for score background sprite.

Definition at line 104 of file HUD.hpp.

Referenced by createScoreHUD().

◆ m_scoreDigitEntities

std::vector< ecs::Entity > gme::HUDSystem::m_scoreDigitEntities
private

Entities for individual score digits.

Definition at line 105 of file HUD.hpp.

Referenced by createScoreHUD().


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