diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-05 21:48:17 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-05 22:09:35 +0200 |
commit | 259219f76c49e6dee0ea7fa0ca09731354fc847f (patch) | |
tree | 29f789a02ce518a9e6fdff26582b8d5e4d00e93b /src | |
parent | 903bf9d6d125ddb035ba2074632da3ff2c8e8d0b (diff) |
short-circuit movement on collision in critter::update
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 fd50c4b9..637324ec 100644 --- a/src/critter.cpp +++ b/src/critter.cpp @@ -187,12 +187,20 @@ void critter::update(size_t i, float dt) offset_frac = Vector2us(Vector2(std::fabs(std::fmod(offset_[0], 1.f)), std::fabs(std::fmod(offset_[1], 1.f))) * frac); auto off_i = Vector2i(offset_); if (!off_i.isZero()) + { if (can_move_to(off_i)) { move_to(i, off_i, new_r); ++frame %= atlas->info().nframes; goto done; } + else + { + offset_frac = {}; + delta = 0; + return; + } + } } delta = 0; break; |