so_long/games/enemy.c

27 lines
737 B
C

int pathfinding(char **map, char **map_cpy, int x, int y, int *check)
{
if (map[x][y] == 'E')
return (1);
map_cpy[x][y] = 'x';
if (map_cpy[x][y + 1] != '1' && map_cpy[x][y + 1] != 'x')
if (is_possible(map, map_cpy, x, y + 1, check))
*check = 1;
if (map_cpy[x + 1][y] != '1' && map_cpy[x + 1][y] != 'x')
if (is_possible(map, map_cpy, x + 1, y, check))
*check = 1;
if (map_cpy[x - 1][y] != '1' && map_cpy[x - 1][y] != 'x')
if (is_possible(map, map_cpy, x - 1, y, check))
*check = 1;
if (map_cpy[x][y - 1] != '1' && map_cpy[x][y - 1] != 'x')
if (is_possible(map, map_cpy, x, y - 1, check))
*check = 1;
if (!has_element(map_cpy, 'C') && *check)
return (1);
return (0);
}
void move_enemy(t_data *data)
{
}