summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/tests/pathfinding.cpp9
-rw-r--r--src/critter.cpp4
-rw-r--r--src/critter.hpp11
3 files changed, 20 insertions, 4 deletions
diff --git a/editor/tests/pathfinding.cpp b/editor/tests/pathfinding.cpp
index cba3f405..f8964c94 100644
--- a/editor/tests/pathfinding.cpp
+++ b/editor/tests/pathfinding.cpp
@@ -149,6 +149,12 @@ void pf_test::update_pre(app& a, const Ns& dt)
auto& C = *a.ensure_player_character(m.world()).ptr;
fm_assert(C.is_dynamic());
+ if (C.movement.L | C.movement.R | C.movement.U | C.movement.D) [[unlikely]]
+ {
+ current.has_value = false;
+ return;
+ }
+
const auto hz = C.atlas->info().fps;
const auto nframes = C.alloc_frame_time(dt, C.delta, hz, C.speed);
@@ -169,6 +175,7 @@ void pf_test::update_pre(app& a, const Ns& dt)
{
current.has_value = false;
Debug{} << "done!" << from;
+ C.set_keys(false, false, false, false);
return;
}
const auto step = next_step(from, current.dest);
@@ -209,8 +216,10 @@ void pf_test::update_pre(app& a, const Ns& dt)
if (!ok) [[unlikely]]
{
+ C.set_keys(false, false, false, false);
C.delta = {};
C.offset_frac = {};
+ current.has_value = false;
}
}
diff --git a/src/critter.cpp b/src/critter.cpp
index 4d275149..5130f09e 100644
--- a/src/critter.cpp
+++ b/src/critter.cpp
@@ -124,12 +124,12 @@ bool critter_proto::operator==(const object_proto& e0) const
void critter::set_keys(bool L, bool R, bool U, bool D)
{
- movement = { L, R, U, D, false };
+ movement = { L, R, U, D, false, false, false, false };
}
void critter::set_keys_auto()
{
- movement = { false, false, false, false, true };
+ movement = { false, false, false, false, true, false, false, false };
}
float critter::depth_offset() const
diff --git a/src/critter.hpp b/src/critter.hpp
index 8855813a..e51d37c2 100644
--- a/src/critter.hpp
+++ b/src/critter.hpp
@@ -42,8 +42,15 @@ struct critter final : object
Vector2us offset_frac; // todo! switch to Vector2ui due to `allocate_frame_time'
struct movement_s {
- bool L : 1, R : 1, U : 1, D : 1, AUTO : 1;
- } movement = {};
+ bool L : 1 = false,
+ R : 1 = false,
+ U : 1 = false,
+ D : 1 = false,
+ AUTO : 1 = false;
+ bool _pad1 : 1 = false,
+ _pad2 : 1 = false,
+ _pad3 : 1 = false;
+ } movement;
bool playable : 1 = false;