Added memorybook to parsing and cleaned most of the files

This commit is contained in:
Philippe BLAGOJEVIC
2022-05-04 14:38:34 +02:00
parent e564e7c8e9
commit 362668fe35
231 changed files with 11474 additions and 405 deletions

View File

@@ -1,34 +1,16 @@
#include "cube3d.h"
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* raycast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/04 13:54:22 by pblagoje #+# #+# */
/* Updated: 2022/05/04 13:54:23 by pblagoje ### ########.fr */
/* */
/* ************************************************************************** */
// tmp draw map
// static void calcul_ray_end(t_rcast *rcast, t_vec *ray)
// {
// if (rcast->is_x)
// {
// ray->end.x = rcast->cell_x * rcast->cell;
// if (rcast->ray_sign_x == 1)
// ray->end.x += rcast->cell;
// if (rcast->slope_x)
// {
// rcast->ratio = (double)(ray->end.x - ray->start.x);
// rcast->ratio /= (double)rcast->slope_x;
// ray->end.y = ray->start.y + (double)rcast->slope_y * rcast->ratio;
// }
// }
// else
// {
// ray->end.y = rcast->cell_y * rcast->cell;
// if (rcast->ray_sign_y == 1)
// ray->end.y += rcast->cell;
// if (rcast->slope_y)
// {
// rcast->ratio = (double)(ray->end.y - ray->start.y);
// rcast->ratio /= (double)rcast->slope_y;
// ray->end.x = ray->start.x + (double)rcast->slope_x * rcast->ratio;
// }
// }
// }
// tmp end
#include "cube3d.h"
static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall)
{
@@ -37,42 +19,22 @@ static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall)
if (rcast->is_x == 1)
{
tmp = wall->delta;
// tmp += rcast->slope_y;
tmp *= -rcast->ray_sign_y;
tmp /= ft_abs(rcast->slope_x);
tmp += game->plr.pos.y;
// tmp draw map
// if (game->ray_activ)
// printf("tmp:%i ", tmp);
// tmp end
wall->posx = tmp % rcast->cell;
}
else
{
tmp = wall->delta;
// tmp += rcast->slope_x;
tmp *= -rcast->ray_sign_x;
tmp /= ft_abs(rcast->slope_y);
tmp += game->plr.pos.x;
// tmp draw map
// if (game->ray_activ)
// printf("tmp:%i ", tmp);
// tmp end
wall->posx = tmp % rcast->cell;
}
// tmp draw map
// if (game->ray_activ)
// printf("wall->posx:%i ", wall->posx);
// tmp end
}
static void fill_wall_vector(t_rcast *rcast, t_wall *wall)
static void fill_wall_vector(t_rcast *rcast, t_wall *wall)
{
int height;
@@ -117,35 +79,10 @@ void raycast(t_game *game, t_rcast *rcast)
rcast->ray_nb = 0;
while (rcast->ray_nb <= rcast->screen_width)
{
// tmp draw map
// // rays
// game->ray_activ = 0;
// if (rcast->ray_nb == game->ray_highlight)
// {
// game->ray_activ = 1;
// game->ray = ray;
// }
// tmp end
ray_intersect_wall(game, rcast, &ray);
// tmp draw map
// calcul_ray_end(rcast, &ray);
// if (game->ray_activ)
// draw_line(&game->map_img, &ray, 0x00FF00FF);
// else if (rcast->ray_nb % 10 == 0)
// draw_line(&game->map_img, &ray, 0x00FFFFFF);
// tmp end
calcul_wall(rcast);
calcul_img_column(game, rcast, &rcast->wall);
draw_column(game, rcast, &rcast->wall, &game->txt);
(rcast->ray_nb)++;
}
// tmp draw map
// printf("\n\n");
// tmp end
}