diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-23 18:04:17 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-03-23 18:08:42 +0100 |
commit | befc31951508740d8e9ae230734d9352246ab515 (patch) | |
tree | 66e98233d2be4e1ce1a1b16f8bd1521cd5267218 /src/critter.cpp | |
parent | c772e3273a9ce6dde9026f24ed8903e335e58375 (diff) |
a
Diffstat (limited to 'src/critter.cpp')
-rw-r--r-- | src/critter.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/critter.cpp b/src/critter.cpp index 8acfac65..221a8256 100644 --- a/src/critter.cpp +++ b/src/critter.cpp @@ -102,12 +102,13 @@ constexpr std::array<rotation, 3> rotation_to_similar(rotation r) template<rotation new_r> bool update_movement_1(critter& C, size_t& i, const anim_def& info, uint32_t nframes) { - const auto rotations = rotation_to_similar(new_r); - const unsigned nvecs = (int)new_r & 1 ? 3 : 1; - bool can_move = false; + constexpr auto rotations = rotation_to_similar(new_r); + constexpr unsigned nvecs = (int)new_r & 1 ? 3 : 1; for (auto k = 0u; k < nframes; k++) { + bool can_move = false; + for (unsigned j = 0; j < nvecs; j++) { const auto vec = rotation_to_vec(rotations[j]); @@ -137,9 +138,12 @@ bool update_movement_1(critter& C, size_t& i, const anim_def& info, uint32_t nfr break; } } + + if (!can_move) + return false; } - return can_move; + return true; } } // namespace |