diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-28 11:49:26 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-28 11:53:53 +0100 |
commit | 1eba2ce44043253f1f9ba8c2366949058a9d7bd4 (patch) | |
tree | 06f11d2613faed00e272241cc0bdd19faaaa86de | |
parent | ebef6441620712b9c82b7cbcae5ae87953b5e10f (diff) |
clean up a bit
-rw-r--r-- | src/critter.cpp | 15 | ||||
-rw-r--r-- | src/critter.hpp | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/critter.cpp b/src/critter.cpp index 02e329c4..9d7c860c 100644 --- a/src/critter.cpp +++ b/src/critter.cpp @@ -118,7 +118,7 @@ int critter::allocate_frame_time(float dt) d = std::min(1., d); auto ret = (int)(d / frame_time); d -= ret; - d = std::max(0., d); + d = Math::clamp(d, 0., 1.); delta = (uint16_t)(d * 65535); return ret; } @@ -144,6 +144,19 @@ Vector2 critter::ordinal_offset(Vector2b offset) const void critter::update(size_t i, float dt) { + if (playable) + update_playable(i, dt); + else + update_nonplayable(i, dt); +} + +void critter::update_nonplayable(size_t i, float dt) +{ + (void)i; (void)dt; (void)playable; +} + +void critter::update_playable(size_t i, float dt) +{ const auto new_r = arrows_to_dir(b_L, b_R, b_U, b_D); if (new_r == rotation_COUNT) { diff --git a/src/critter.hpp b/src/critter.hpp index cfb6acb3..f419c745 100644 --- a/src/critter.hpp +++ b/src/critter.hpp @@ -27,6 +27,8 @@ struct critter final : object explicit operator critter_proto() const; void update(size_t i, float dt) override; + void update_playable(size_t i, float dt); + void update_nonplayable(size_t i, float dt); void set_keys(bool L, bool R, bool U, bool D); Vector2 ordinal_offset(Vector2b offset) const override; float depth_offset() const override; |