diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-23 14:48:17 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-23 14:48:17 +0100 |
commit | f66346f89796ae109fc1ba4269764fadd9fcfeab (patch) | |
tree | 5091b85bb0e969de975f90ee64340573a03662f9 /src/critter.cpp | |
parent | 85dc6cd001934b1d79e0caed513cd48cb598f4f2 (diff) |
a
Diffstat (limited to 'src/critter.cpp')
-rw-r--r-- | src/critter.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/critter.cpp b/src/critter.cpp index 3602b530..6aec78c8 100644 --- a/src/critter.cpp +++ b/src/critter.cpp @@ -125,7 +125,7 @@ bool critter_proto::operator==(const object_proto& e0) const void critter::set_keys(bool L, bool R, bool U, bool D) { - movement = { L, R, U, D, false, false, false, false }; + movement = { L, R, U, D, movement.AUTO, false, false, false }; } void critter::set_keys_auto() @@ -146,8 +146,10 @@ Vector2 critter::ordinal_offset(Vector2b offset) const void critter::update(size_t i, const Ns& dt) { - if (playable) + if (playable) [[unlikely]] { + movement.AUTO &= !(movement.L | movement.R | movement.U | movement.D); + if (!movement.AUTO) { const auto new_r = arrows_to_dir(movement.L, movement.R, movement.U, movement.D); @@ -202,7 +204,7 @@ void critter::update_movement(size_t i, const Ns& dt, rotation new_r) auto off_i = Vector2i(offset_); if (!off_i.isZero()) { - auto rem = (offset_ - Vector2(off_i)).length(); + auto rem = Math::fmod(offset_, 1.f).length(); offset_frac_ = Frac(rem * frac); if (can_move_to(off_i)) { |