summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-02-04 13:44:45 +0100
committerAki <please@ignore.pl>2023-02-04 13:44:45 +0100
commitdedd9566a53de73215a13117e2704e8df4d04e95 (patch)
tree3d2756959674c42c80e781e006ac6602301cc882
parent9a456b0e0d2f5505ced3751a0bbfc10c2dd1d233 (diff)
downloadkurator-dedd9566a53de73215a13117e2704e8df4d04e95.zip
kurator-dedd9566a53de73215a13117e2704e8df4d04e95.tar.gz
kurator-dedd9566a53de73215a13117e2704e8df4d04e95.tar.bz2
Added wonky visual speed indicators
-rw-r--r--kurator/src/Battle.cpp18
1 files 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 <raylib.h>
#include <imgui.h>
+#include <kurator/engine/Point.h>
#include <kurator/campaign/scenarios.h>
#include <kurator/sim/Battle.h>
#include <kurator/sim/components.h>
#include <kurator/sim/events.h>
+#include <kurator/sim/FloatingMovement.h>
#include <kurator/stats/events.h>
#include <kurator/universe/ShipType.h>
#include <kurator/universe/UniqueIdentifier.h>
@@ -162,13 +164,17 @@ Battle::draw() const
auto view = registry.view<const Marker, const sim::Transform>();
for (auto [entity, marker, transform] : view.each()) {
const auto pos = camera.to_screen(transform.position);
+ if (registry.all_of<sim::FloatingMovement>(entity)) {
+ const auto& movement = registry.get<sim::FloatingMovement>(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<CenteredText, sim::Transform, UIOffset>();