summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-29 16:06:49 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-01 06:06:48 +0100
commit74387a4aa6117abcc814bc26c3c9ede98fdfa5bc (patch)
tree2eef7f0ebd29f96891a4baa3c0cda7b60007b669
parentc5b012ecf8d809dfda764f57050f985b0fcbf4d6 (diff)
wip critter
-rw-r--r--src/critter.cpp24
-rw-r--r--src/critter.hpp2
2 files changed, 15 insertions, 11 deletions
diff --git a/src/critter.cpp b/src/critter.cpp
index 8be3678b..77933b77 100644
--- a/src/critter.cpp
+++ b/src/critter.cpp
@@ -142,7 +142,16 @@ Vector2 critter::ordinal_offset(Vector2b offset) const
void critter::update(size_t i, float dt)
{
if (playable)
- update_playable(i, dt);
+ {
+ const auto new_r = arrows_to_dir(b_L, b_R, b_U, b_D);
+ if (new_r == rotation_COUNT)
+ {
+ offset_frac = {};
+ delta = 0;
+ }
+ else
+ update_movement(i, dt, new_r);
+ }
else
update_nonplayable(i, dt);
}
@@ -152,15 +161,10 @@ void critter::update_nonplayable(size_t i, float dt)
(void)i; (void)dt; (void)playable;
}
-void critter::update_playable(size_t i, float dt)
+void critter::update_movement(size_t i, float dt, rotation new_r)
{
- const auto new_r = arrows_to_dir(b_L, b_R, b_U, b_D);
- if (new_r == rotation_COUNT)
- {
- offset_frac = {};
- delta = 0;
- return;
- }
+ fm_assert(new_r < rotation_COUNT);
+ fm_assert(is_dynamic());
int nframes = allocate_frame_time(dt * speed);
if (nframes == 0)
@@ -171,7 +175,7 @@ void critter::update_playable(size_t i, float dt)
const unsigned nvecs = (int)new_r & 1 ? 3 : 1;
if (r != new_r)
- if (is_dynamic())
+ //if (is_dynamic())
rotate(i, new_r);
c->ensure_passability();
diff --git a/src/critter.hpp b/src/critter.hpp
index f419c745..a6e9e4cc 100644
--- a/src/critter.hpp
+++ b/src/critter.hpp
@@ -27,7 +27,7 @@ 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_movement(size_t i, float dt, rotation r);
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;