From 372874309543e78b26472f89125d11f8a19f9e88 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 6 Mar 2024 00:05:56 +0100 Subject: test/critter: don't stop iterating on fractional movement --- src/critter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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; } -- cgit v1.2.3