From ae71e259fd2a39cc73e266c85ca44d658ac1f976 Mon Sep 17 00:00:00 2001 From: Klemen Plestenjak Date: Sat, 10 Feb 2024 09:36:29 +0100 Subject: [PATCH] Hide health bar, if it was not changed --- game/systems/s_entity.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/game/systems/s_entity.c b/game/systems/s_entity.c index 781d928..cad6fa8 100644 --- a/game/systems/s_entity.c +++ b/game/systems/s_entity.c @@ -389,7 +389,12 @@ void renderHealthBar(ecs_iter_t *it) { HitBox *hitbox = ecs_field(it, HitBox, 2); Health *health = ecs_field(it, Health, 3); + f32 time = GetTime(); + for (i32 i = 0; i < it->count; i++) { + f32 lastChange = time - health[i].lastChanged; + if (lastChange > 2.0f) continue; + HitBox hb = entityTransformHitBox(pos[i], hitbox[i]); const f32 HP_WIDTH = 10.0f; const f32 HP_HEIGHT = 1.8f;