From 3f450f7bfe7f166c324e5eca207fb6b9bebb175c Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 4 Dec 2022 23:54:30 +0100 Subject: Width and height are now predivided by two --- kurator/src/Battle.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index 8d28dba..3f7d39e 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -71,31 +71,31 @@ void Battle::draw() const { ClearBackground(BLACK); - const int width = GetScreenWidth(); - const int height = GetScreenHeight(); - const double scale = std::min(width/30000.0, height/30000.0); + const int hwidth = GetScreenWidth() / 2; + const int hheight = GetScreenHeight() / 2; + const double scale = std::min(hwidth/15000.0, hheight/15000.0); auto& registry = battle->registry(); auto lines = registry.view(); for (const auto& [entity, line] : lines.each()) { DrawLine( - width/2 + line.start.x*scale, - height/2 + line.start.y*scale, - width/2 + line.end.x*scale, - height/2 + line.end.y*scale, + hwidth + line.start.x*scale, + hheight + line.start.y*scale, + hwidth + line.end.x*scale, + hheight + line.end.y*scale, line.color); } auto view = registry.view(); for (auto [entity, marker, transform] : view.each()) { - const int x = width/2 + transform.position.x*scale; - const int y = height/2 + transform.position.y*scale; + const int x = hwidth + transform.position.x*scale; + const int y = hheight + transform.position.y*scale; DrawCircle(x, y, marker.radius, marker.color); 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, 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; + const int x = hwidth + transform.position.x*scale - text.width/2 + offset.x; + const int y = hheight + 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(); @@ -104,10 +104,10 @@ Battle::draw() const 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 x1 = hwidth / 2.0; + const int w1 = hwidth * totals[1] / (totals[0] + totals[1]); const int x2 = x1 + w1; - const int w2 = width / 2.0 * totals[0] / (totals[0] + totals[1]); + const int w2 = hwidth * totals[0] / (totals[0] + totals[1]); DrawRectangle(x1, 10, w1, 10, GREEN); DrawRectangle(x2, 10, w2, 10, RED); } -- cgit v1.1