mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
feat: Made doors opening and closing
This commit is contained in:
parent
b606159ac3
commit
47ffb17047
5 changed files with 12 additions and 7 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/30 17:32:50 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/10/01 13:50:59 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/03 17:02:08 by tchampio #+# #+# */
|
||||
/* Updated: 2025/09/30 17:35:31 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/10/01 13:51:03 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/06 11:25:05 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/30 17:43:36 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/10/01 13:43:22 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/31 11:55:41 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/30 23:05:11 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/10/01 13:50:08 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ void ray_calculate_step(t_ray *ray, t_player *player)
|
|||
|
||||
void handle_door_ray(t_ray *ray, t_cub3d_data *data)
|
||||
{
|
||||
if (data->map->map[ray->map_y][ray->map_x] == 'd' && ray->wall_dist < 1.5)
|
||||
if ((data->map->map[ray->map_y][ray->map_x] == 'd' || data->map->map[ray->map_y][ray->map_x] == 'i') && ray->wall_dist < 1.5)
|
||||
{
|
||||
ft_printf("map[%d][%d] = door reachable\n", ray->map_y, ray->map_x);
|
||||
data->player.closest_door[0] = ray->map_x;
|
||||
|
|
@ -69,7 +69,10 @@ void handle_door_ray(t_ray *ray, t_cub3d_data *data)
|
|||
if (data->keypresses.is_f_pressed)
|
||||
{
|
||||
data->keypresses.is_f_pressed = false;
|
||||
data->map->map[ray->map_y][ray->map_x] = 'i';
|
||||
if (data->map->map[ray->map_y][ray->map_x] == 'd')
|
||||
data->map->map[ray->map_y][ray->map_x] = 'i';
|
||||
else if (data->map->map[ray->map_y][ray->map_x] == 'i')
|
||||
data->map->map[ray->map_y][ray->map_x] = 'd';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -86,6 +89,8 @@ void calculate_wall_dist(t_ray *ray, int x, t_cub3d_data *data)
|
|||
{
|
||||
if (x == WIDTH / 2)
|
||||
check_for_zombies(ray, data);
|
||||
if (!blocks_view(data->map, ray->map_x, ray->map_y) && data->map->map[ray->map_y][ray->map_x] == 'i')
|
||||
handle_door_ray(ray, data);
|
||||
if (ray->side_dist_x < ray->side_dist_y)
|
||||
{
|
||||
ray->side_dist_x += ray->delta_dist_x;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/31 13:17:39 by kcolin #+# #+# */
|
||||
/* Updated: 2025/09/30 17:41:52 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/10/01 13:36:58 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue