cub3d/src/collision.c
2025-04-22 14:44:15 +02:00

31 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* collision.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/22 14:40:59 by qmennen #+# #+# */
/* Updated: 2025/04/22 14:42:09 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
#include "collision.h"
int collision_horizontal(t_map *map, t_player *player, float xa)
{
t_tile tile;
tile = get_tile(map, (int) ((player->pos.x + xa) / TILE_SIZE), (int) ((player->pos.y) / TILE_SIZE));
return (tile != TILE_WALL && tile != TILE_VOID);
}
int collision_vertical(t_map *map, t_player *player, float ya)
{
t_tile tile;
tile = get_tile(map, (int) ((player->pos.x) / TILE_SIZE), (int) ((player->pos.y + ya) / TILE_SIZE));
return (tile != TILE_WALL && tile != TILE_VOID);
}