fix: Fixed door closing and stucking player if on the same tile

This commit is contained in:
Theo Champion 2025-10-03 19:31:05 +02:00
parent 437b76a68c
commit efe33ec6c5

View file

@ -14,6 +14,11 @@
#include "../../libft/includes/libft.h"
#include "../player/pay.h"
bool check_door_pos(t_cub3d_data *data)
{
return (data->map->map[(int)data->player.y][(int)data->player.x] == 'i');
}
void handle_door_ray(t_ray *ray, t_cub3d_data *data)
{
char current_tile;
@ -31,7 +36,7 @@ void handle_door_ray(t_ray *ray, t_cub3d_data *data)
data->map->map[ray->map_y][ray->map_x] = 'i';
else if (current_tile == 'P' && pay(data, data->door_amount, true))
data->map->map[ray->map_y][ray->map_x] = '0';
else if (current_tile == 'i')
else if (current_tile == 'i' && !check_door_pos(data))
data->map->map[ray->map_y][ray->map_x] = 'd';
}
}