11 .with<ecs::Scale>(
"score_bg_scale", 3.0f, 2.0f)
13 .with<ecs::Layer>(
"score_bg_layer", 1)
17 for (
int i = 0; i < 6; ++i)
21 .with<ecs::Scale>(
"score_digit_scale", 1.0f, 1.0f)
23 .with<ecs::Layer>(
"score_digit_layer", 2)
32 for (
int i = 5; i >= 0; --i)
34 digits[i] = newScore % 10;
38 static const char *digitPaths[10] = {
45 for (
int i = 0; i < 6 && i < m_scoreDigitEntities.size(); ++i)
49 digitTexture->path = digitPaths[digits[i]];
54 (digitTransform !=
nullptr) && (digitScale !=
nullptr))
56 digitTransform->
x = 10.0f + 130.0f + i * 20.0f;
57 digitTransform->y = 10.0f + 4.0f;
69 currentScore = score.value;
73 updateScore(registry, currentScore);
This file contains the component definitions.
Heads-Up Display (HUD) system for R-Type multiplayer game.
EntityBuilder & with(Args &&...args)
Class for managing entities and their components.
EntityBuilder createEntity()
std::unordered_map< Entity, T > & getAll()
T * getComponent(Entity e)
void update(ecs::Registry ®istry, float) override
Update the HUD system (called each frame)
void updateScore(ecs::Registry ®istry, int newScore) const
Update the displayed score value.
std::vector< ecs::Entity > m_scoreDigitEntities
Entities for individual score digits.
ecs::Entity m_scoreBgEntity
Entity for score background sprite.
void createScoreHUD(ecs::Registry ®istry, float x, float y)
Create the score display HUD elements.
This file contains common definitions and constants.
constexpr auto TEXTURE_SCORE_DIGIT_3
constexpr auto TEXTURE_SCORE_DIGIT_5
constexpr auto TEXTURE_SCORE_DIGIT_2
constexpr auto TEXTURE_SCORE_DIGIT_9
constexpr auto TEXTURE_SCORE_DIGIT_6
constexpr auto TEXTURE_SCORE_DIGIT_1
constexpr auto TEXTURE_SCORE_DIGIT_4
constexpr auto TEXTURE_SCORE_COUNTER_BG
constexpr auto TEXTURE_SCORE_DIGIT_0
constexpr auto TEXTURE_SCORE_DIGIT_8
constexpr auto TEXTURE_SCORE_DIGIT_7