42_cube3D/game/raycasting.c
Etienne Rey-bethbeder bef4863660 _
2023-05-05 14:00:20 +02:00

42 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* raycasting.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 14:30:29 by erey-bet #+# #+# */
/* Updated: 2023/05/05 13:59:57 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "game.h"
int ray(t_game *game)
{
t_ply *p;
t_ray *ray;
double camera;
int x;
x = 0;
p = &game->ply;
ray = &game->ray;
while (x < WIDTH)
{
camera = 2 * x / (double)WIDTH - 1;
ray->dir_x = p->dir_x + p->pla_x * camera;
ray->dir_y = p->dir_y + p->pla_y * camera;
dda(game, x);
x++;
}
return(0);
}
int raycasting(t_game *game)
{
ray(game);
return (0);
}