diff options
author | Aki <please@ignore.pl> | 2022-11-20 15:50:04 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-11-20 15:50:04 +0100 |
commit | 181ad14d537d75a97a8d830d70f7d9486f26ee1d (patch) | |
tree | 534dd05df7e20d5e3a7e7b2558a88ee37f70f6ef /battles/src | |
parent | b4b20596af5a61088d7085d562bfdaef2c093578 (diff) | |
download | kurator-181ad14d537d75a97a8d830d70f7d9486f26ee1d.zip kurator-181ad14d537d75a97a8d830d70f7d9486f26ee1d.tar.gz kurator-181ad14d537d75a97a8d830d70f7d9486f26ee1d.tar.bz2 |
FloatingMovment now changes angle when updating
Diffstat (limited to 'battles/src')
-rw-r--r-- | battles/src/BaseBattle.cpp | 1 | ||||
-rw-r--r-- | battles/src/Point.cpp | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/battles/src/BaseBattle.cpp b/battles/src/BaseBattle.cpp index eb75464..0de18d5 100644 --- a/battles/src/BaseBattle.cpp +++ b/battles/src/BaseBattle.cpp @@ -104,6 +104,7 @@ BaseBattle::floating_movement(const float dt) const auto speed = movement.speed.scale(dt); transform.position.x += speed.x; transform.position.y += speed.y; + transform.angle = speed.angle(); } } diff --git a/battles/src/Point.cpp b/battles/src/Point.cpp index 9ffa81c..31aecae 100644 --- a/battles/src/Point.cpp +++ b/battles/src/Point.cpp @@ -23,6 +23,13 @@ Point::distance(const Point& other) const } +double +Point::angle() const +{ + return std::atan2(y, x); // (+x, _) is 0 +} + + Point Point::rotate(const double angle) const { |