42_cube3D/game/raycasting.c
Etienne Rey-bethbeder da452769c2 _
2023-05-02 15:39:16 +02:00

40 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* raycasting.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 14:30:29 by erey-bet #+# #+# */
/* Updated: 2023/05/02 13:12:15 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "game.h"
int ray(t_game *game)
{
t_ply *p;
t_ray *ray;
double camera;
int i;
i = 0;
p = game->ply;
ray = game->ray;
while (i <= WIDTH)
{
camera = 2 * i / (double)WIDTH - 1; //x-coordinate in camera space
ray->x = p->dir_x + p->pla_x * camera;
ray->y = p->dir_y + p->pla_y * camera;
}
}
int raycasting(t_game *game)
{
(void)game;
ray(game)
write(1, "raycasting...\n", 14);
return (0);
}