From c2ecf09c29bc1d06336f372621ba37eba5f9875b Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 20 Nov 2022 22:42:23 +0100 Subject: Added force balance slide --- kurator/src/Battle.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index cb97ce7..08cc6dc 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -89,6 +89,18 @@ Battle::draw() const const int y = height/2 + transform.position.y*scale - text.font_size/2; DrawText(text.text.c_str(), x, y, text.font_size, text.color); } + auto points = registry.view(); + double totals[2] {0.0, 0.0}; // FIXME and extract + for (const auto& [entity, points, team] : points.each()) { + if (team.id < 2) + totals[team.id] += points.health; + } + const int x1 = width / 4.0; + const int w1 = width / 2.0 * totals[1] / (totals[0] + totals[1]); + const int x2 = x1 + w1; + const int w2 = width / 2.0 * totals[0] / (totals[0] + totals[1]); + DrawRectangle(x1, 10, w1, 10, GREEN); + DrawRectangle(x2, 10, w2, 10, RED); } -- cgit v1.1