#include "movement.h" #include "enemy.h" #include "map/map.h" #include // Check if position is occupied by player static int is_player_at(Player *p, int x, int y) { return (p->position.x == x && p->position.y == y); } MoveResult try_move_entity(Vec2 *p, Vec2 direction, Map *map, Player *player, Enemy *enemies, int enemy_count, bool moving_is_player) { int new_x = p->x + direction.x; int new_y = p->y + direction.y; if (!is_floor(map, new_x, new_y)) return MOVE_RESULT_BLOCKED_WALL; if (is_enemy_at(enemies, enemy_count, new_x, new_y)) return MOVE_RESULT_BLOCKED_ENEMY; if (!moving_is_player) { if (is_player_at(player, new_x, new_y)) return MOVE_RESULT_BLOCKED_PLAYER; } p->x = new_x; p->y = new_y; return MOVE_RESULT_MOVED; }