Center floaty text

This commit is contained in:
2024-02-10 13:26:03 +01:00
parent 1487d67a3b
commit e1e4448751

View File

@@ -27,6 +27,10 @@ void damageEvent(ecs_entity_t entity, DamageEvent event) {
.elapsed = 0
};
snprintf(floatyText.text, sizeof(floatyText.text), "-%.1f", event.amount);
const Game *game = ecs_singleton_get(ECS, Game);
Vector2 textSize = MeasureTextEx(game->font, floatyText.text, floatyText.txtSize, 1.0f);
floatyText.pos.x -= textSize.x * 0.5f;
floatyText.pos.y -= textSize.y * 0.5f;
ecs_entity_t floaty = entityCreateEmpty();
ecs_set_ptr(ECS, floaty, FloatyTextParticle, &floatyText);