diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-06 00:05:56 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-06 00:05:56 +0100 |
commit | 372874309543e78b26472f89125d11f8a19f9e88 (patch) | |
tree | 096a00c185f52303f03890c04988580cb3ae7579 /src | |
parent | cd06aed7c3aaafe665d1d18e6e9032e4bf7b4aef (diff) |
test/critter: don't stop iterating on fractional movement
Diffstat (limited to 'src')
-rw-r--r-- | src/critter.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/critter.cpp b/src/critter.cpp index 4ec00059..f9de8638 100644 --- a/src/critter.cpp +++ b/src/critter.cpp @@ -172,6 +172,7 @@ void critter::update_movement(size_t i, Ns dt, rotation new_r) rotate(i, new_r); c->ensure_passability(); + bool can_move = false; for (auto k = 0u; k < nframes; k++) { @@ -188,6 +189,7 @@ void critter::update_movement(size_t i, Ns dt, rotation new_r) offset_frac = Vector2us(Math::abs(Math::fmod(offset_, 1.f)) * frac); if (can_move_to(off_i)) { + can_move = true; move_to(i, off_i, new_r); ++frame %= atlas->info().nframes; break; @@ -200,6 +202,12 @@ void critter::update_movement(size_t i, Ns dt, rotation new_r) } } } + + if (!can_move) + { + delta = {}; + offset_frac = {}; + } } object_type critter::type() const noexcept { return object_type::critter; } |