From dedd9566a53de73215a13117e2704e8df4d04e95 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 4 Feb 2023 13:44:45 +0100 Subject: Added wonky visual speed indicators --- kurator/src/Battle.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index 9bb5dec..ce14365 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -10,10 +10,12 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -162,13 +164,17 @@ Battle::draw() const auto view = registry.view(); for (auto [entity, marker, transform] : view.each()) { const auto pos = camera.to_screen(transform.position); + if (registry.all_of(entity)) { + const auto& movement = registry.get(entity); + const auto& velocity = movement.speed; + const auto edge = pos + velocity.normalized().scale(marker.radius); + const auto tip = edge + velocity.scale(2.0 * camera.scale); + DrawLine(edge.x, edge.y, tip.x, tip.y, DARKGRAY); + } + const engine::Point direction {std::cos(transform.angle), std::sin(transform.angle)}; + const auto edge = pos + direction.scale(marker.radius); DrawCircle(pos.x, pos.y, marker.radius, marker.color); - DrawLine( - pos.x, - pos.y, - pos.x + marker.radius*std::cos(transform.angle), - pos.y + marker.radius*std::sin(transform.angle), - WHITE); + DrawLine(pos.x, pos.y, edge.x, edge.y, WHITE); DrawText(marker.name.c_str(), pos.x+10, pos.y-5, 10.0f, GRAY); } auto pops = registry.view(); -- cgit v1.1