so_long/games/enemy.c
Etienne Rey-bethbeder 8c14fce5ee avancement
2023-01-02 18:05:09 +01:00

31 lines
703 B
C

void distance_player(char **map, int x, int y, int nbr)
{
map[x][y] = nbr + '0';
if (map[x][y + 1] != '1' && map[x][y + 1] == '0')
distance_player(map, x, y + 1, nbr + 1)
if (map[x + 1][y] != '1' && map[x + 1][y] == '0')
distance_player(map, x + 1, y, nbr + 1)
if (map[x - 1][y] != '1' && map[x + 1][y] == '0')
distance_player(map, x - 1, y, nbr + 1)
if (map[x][y - 1] != '1' && map[x][y - 1] == '0')
distance_player(map, x, y - 1, nbr + 1)
}
t_xy path_finding(t_data *data, int x, int y)
{
t_xy new_pos;
char **map_cpy;
if (cur.x == ply.x && cur.y == ply.y)
return (0);
map_cpy = ft_strdups(data->map);
distance_player(map_cpy, x, y, 0);
}
void move_enemy(t_data *data)
{
}