From 18eba7f30381c05ee1c03bec5f537ec7d4dc9815 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 27 Nov 2022 19:08:44 +0100 Subject: Fixed damage pop ups not popping up properly --- kurator/src/Battle.cpp | 19 ++++++++++--------- kurator/src/components.h | 5 +++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index da4e34a..28c24c1 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -53,11 +53,11 @@ Battle::update(const float dt) if (timer.left < 0.0) registry.destroy(entity); } - auto pops = registry.view(); - for (auto&& [entity, pop, transform] : pops.each()) { + auto pops = registry.view(); + for (auto&& [entity, pop, offset] : pops.each()) { const auto speed = pop.speed.scale(dt); - transform.position.x += speed.x; - transform.position.y += speed.y; + offset.x += speed.x; + offset.y += speed.y; const auto damp = pop.speed.scale(pop.damp).scale(dt); pop.speed.x -= damp.x; pop.speed.y -= damp.y; @@ -83,10 +83,10 @@ Battle::draw() const DrawLine(x, y, x + marker.radius*std::cos(transform.angle), y + marker.radius*std::sin(transform.angle), WHITE); DrawText(marker.name.c_str(), x+10, y-10, 20.0f, GRAY); } - auto pops = registry.view(); - for (const auto& [entity, text, transform] : pops.each()) { - const int x = width/2 + transform.position.x*scale - text.width/2; - const int y = height/2 + transform.position.y*scale - text.font_size/2; + auto pops = registry.view(); + for (const auto& [entity, text, transform, offset] : pops.each()) { + const int x = width/2 + transform.position.x*scale - text.width/2 + offset.x; + const int y = height/2 + transform.position.y*scale - text.font_size/2 + offset.y; DrawText(text.text.c_str(), x, y, text.font_size, text.color); } auto points = registry.view(); @@ -116,7 +116,8 @@ Battle::receive(const battles::Hit& hit) registry.emplace(entity, 1.2); registry.emplace(entity, text, MeasureText(text.c_str(), 10), 10, RED); registry.emplace(entity, transform.position, 0.0); - registry.emplace(entity, battles::Point{0.0, -0.6}, 0.998); + registry.emplace(entity, 0, 0); + registry.emplace(entity, battles::Point{0.0, -20}, 0.9998); } diff --git a/kurator/src/components.h b/kurator/src/components.h index 6e03412..5a6a43e 100644 --- a/kurator/src/components.h +++ b/kurator/src/components.h @@ -26,6 +26,11 @@ struct CenteredText }; +struct UIOffset : public battles::Point +{ +}; + + struct PopMove { battles::Point speed; -- cgit v1.1