movement: generalize; use vectors #16

Merged
NotAShelf merged 6 commits from SquirrelModeler/rogged:generalize-movement into main 2026-04-09 14:11:47 +00:00
Showing only changes of commit 4044543fe1 - Show all commits

fix: move guard check

I am stupid. I added the guard on the wrong check. Ffs...
Squirrel Modeller 2026-04-09 15:28:57 +02:00
No known key found for this signature in database
GPG key ID: C9FBA7B8C387BF70

View file

@ -446,14 +446,14 @@ static int handle_movement_input(GameState *gs) {
MoveResult result =
try_move_entity(&gs->player.position, direction, &gs->map, &gs->player, gs->enemies, gs->enemy_count, true);
if (result == MOVE_RESULT_MOVED) {
if (target != NULL) {
player_on_move(&gs->player);
}
player_on_move(&gs->player);
action = 1;
} else if (result == MOVE_RESULT_BLOCKED_ENEMY) {
target = player_find_enemy_at(gs->enemies, gs->enemy_count, new_x, new_y);
player_attack(&gs->player, target);
action = 1;
if (target != NULL) {
player_attack(&gs->player, target);
action = 1;
}
}
if (action)