cub3d/src/map/collision.c

39 lines
1.4 KiB
C
Raw Normal View History

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* collision.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/06 11:25:05 by kcolin #+# #+# */
2025-10-01 14:13:08 +02:00
/* Updated: 2025/10/01 14:11:11 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
#include "collision.h"
#include "../../libft/includes/libft.h"
static bool out_of_bounds(t_mapdata *data, int x, int y)
{
if (x < 0
|| y < 0
|| y >= data->mapheight
|| x > (int)ft_strlen(data->map[y]))
return (true);
return (false);
}
bool blocks_movement(t_mapdata *data, int x, int y)
{
2025-10-01 17:40:07 +02:00
if (out_of_bounds(data, x, y) || ft_strchr("12345678dP", data->map[y][x]))
return (true);
return (false);
}
bool blocks_view(t_mapdata *data, int x, int y)
{
2025-10-01 14:13:08 +02:00
if (out_of_bounds(data, x, y) || ft_strchr("12345678dP", data->map[y][x]))
return (true);
return (false);
}