summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-12-04 23:54:30 +0100
committerAki <please@ignore.pl>2022-12-04 23:54:30 +0100
commit3f450f7bfe7f166c324e5eca207fb6b9bebb175c (patch)
tree6a1bc517cbabb821d9bd7a03ea3f0d3e94389de6
parent2860d6e665e908e8a66c147ea45ea6398959c628 (diff)
downloadkurator-3f450f7bfe7f166c324e5eca207fb6b9bebb175c.zip
kurator-3f450f7bfe7f166c324e5eca207fb6b9bebb175c.tar.gz
kurator-3f450f7bfe7f166c324e5eca207fb6b9bebb175c.tar.bz2
Width and height are now predivided by two
-rw-r--r--kurator/src/Battle.cpp28
1 files 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<Line>();
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<const Marker, const sim::Transform>();
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<CenteredText, sim::Transform, UIOffset>();
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<sim::HitPoints, sim::Team>();
@@ -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);
}