tmp bring back rays and highlight for debug purpose
This commit is contained in:
@@ -1,5 +1,35 @@
|
||||
#include "cube3d.h"
|
||||
|
||||
// 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
|
||||
|
||||
static void calcul_img_column(t_game *game, t_rcast *rcast, t_wall *wall)
|
||||
{
|
||||
int tmp;
|
||||
@@ -63,7 +93,24 @@ 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;
|
||||
//if (game->ray_activ) printf("hello\n");
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user