Skip to content

Commit

Permalink
src/critter: fix stopping auto movement
Browse files Browse the repository at this point in the history
  • Loading branch information
sthalik committed Mar 23, 2024
1 parent c5edaad commit 20762b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions editor/tests/pathfinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -211,6 +217,7 @@ void pf_test::update_pre(app& a, const Ns& dt)
{
C.delta = {};
C.offset_frac = {};
current.has_value = false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/critter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ 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;
} movement;

bool playable : 1 = false;

Expand Down

0 comments on commit 20762b4

Please sign in to comment.