Files
42_INT_10_cube3d/srcs/player/player_limits.c
2022-05-02 09:39:03 +02:00

31 lines
638 B
C

#include "cube3d.h"
int is_wall(t_game *game, int cell_x, int cell_y)
{
if (cell_x < 0 || cell_y < 0)
return (1);
if (cell_x > game->map.size_x || cell_y > game->map.size_y)
return (1);
if (game->map.content[cell_y][cell_x] != '0')
return (1);
return (0);
}
int plr_out_limits(t_game *game, int x, int y)
{
int xmax;
int ymax;
int cell_x;
int cell_y;
xmax = game->map.size_x * game->map.cell;
ymax = game->map.size_y * game->map.cell;
cell_x = x / game->map.cell;
cell_y = y / game->map.cell;
if (is_wall(game, cell_x, cell_y))
return (1);
if (x < 0 || y < 0 || x > xmax || y > ymax)
return (1);
return (0);
}