2025-08-06 11:24:15 +02:00
|
|
|
/* ************************************************************************** */
|
|
|
|
|
/* */
|
|
|
|
|
/* ::: :::::::: */
|
|
|
|
|
/* 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 */
|
2025-08-06 11:24:15 +02:00
|
|
|
/* */
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
|
|
#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
|
2025-08-20 12:48:48 +02:00
|
|
|
|| y >= data->mapheight
|
|
|
|
|
|| x > (int)ft_strlen(data->map[y]))
|
2025-08-06 11:24:15 +02:00
|
|
|
return (true);
|
|
|
|
|
return (false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool blocks_movement(t_mapdata *data, int x, int y)
|
|
|
|
|
{
|
2025-09-30 17:50:49 +02:00
|
|
|
if (out_of_bounds(data, x, y) || ft_strchr("12345678d", data->map[y][x]))
|
2025-08-06 11:24:15 +02:00
|
|
|
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]))
|
2025-08-06 11:24:15 +02:00
|
|
|
return (true);
|
|
|
|
|
return (false);
|
|
|
|
|
}
|