42_cube3D/game/raycasting.c

40 lines
1.3 KiB
C
Raw Normal View History

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* raycasting.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 14:30:29 by erey-bet #+# #+# */
2023-05-03 06:45:40 -04:00
/* Updated: 2023/05/03 12:45:15 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "game.h"
2023-05-02 09:39:16 -04:00
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
2023-05-02 10:58:55 -04:00
ray->dir_x = p->dir_x + p->pla_x * camera;
ray->dir_y = p->dir_y + p->pla_y * camera;
2023-05-02 09:39:16 -04:00
}
2023-05-03 06:45:40 -04:00
return(0);
2023-05-02 09:39:16 -04:00
}
int raycasting(t_game *game)
{
2023-05-03 06:45:40 -04:00
ray(game);
write(1, "raycasting...\n", 14);
return (0);
}