diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2020-02-17 17:46:11 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2020-02-17 17:46:11 +0100 |
commit | 39b3e74b166e69814d2bec2853d6b53cf274af78 (patch) | |
tree | b3c28ed051f1951a80f2d6b45b1210b4c98eae50 | |
parent | Norme (diff) | |
download | 42-cub3d-39b3e74b166e69814d2bec2853d6b53cf274af78.tar.gz 42-cub3d-39b3e74b166e69814d2bec2853d6b53cf274af78.tar.bz2 42-cub3d-39b3e74b166e69814d2bec2853d6b53cf274af78.tar.xz 42-cub3d-39b3e74b166e69814d2bec2853d6b53cf274af78.tar.zst 42-cub3d-39b3e74b166e69814d2bec2853d6b53cf274af78.zip |
add shadows and beginning of wall coordinate hit detection
-rw-r--r-- | map/map_one.cub | 28 | ||||
-rw-r--r-- | src/ft_draw_verline.c | 2 | ||||
-rw-r--r-- | src/ft_raycasting.c | 9 |
3 files changed, 22 insertions, 17 deletions
diff --git a/map/map_one.cub b/map/map_one.cub index b2635f8..00bd7db 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -9,17 +9,17 @@ S ./map/img/segfot.xpm C 50,100,200 F 150,150,124 -11111111111111111 1 -1 00000000011000001 -1N0100000000000001 -101100000111000001 -111111111111111111 -100000000011000001 -111101111111110111 -111101111111110111 -11000 0001101010111 -100020000000000011 -100000000000000011 -1100000011010101 11 -111101111111010111 -111111111111111111 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 +1 0 0 1 0 0 0 0 0 0 0 0 0 0 W 0 0 1 +1 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 +1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 +1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 +1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 +1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 1 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 +1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 +1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c index bcddbc7..0fad33a 100644 --- a/src/ft_draw_verline.c +++ b/src/ft_draw_verline.c @@ -60,7 +60,7 @@ int8_t ft_choose_tex(cl); while (y <= y2) { - *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = 0x0000ffaa; + *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = (cl->rlist.side) ? 0x0000eeaa : 0x0000ffaa; y++; } ft_draw_floor(cl, y, x); diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 98f1c81..7ce45d5 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -10,19 +10,23 @@ /* */ /* ************************************************************************** */ +#include <libft.h> #include <cub3d.h> #include <stdint.h> #include <stdio.h> +#include <math.h> void ft_calc_tex(t_cub *clist) { - if (clist->rlist.side == 1) + if (clist->rlist.side == 0) clist->rlist.wall_hit_x = clist->plist->pos_y + clist->rlist.wall_dist * clist->rlist.y_ray_dir; else clist->rlist.wall_hit_x = clist->plist->pos_x + clist->rlist.wall_dist * clist->rlist.x_ray_dir; + clist->rlist.wall_hit_x -= floor(clist->rlist.wall_hit_x); + /*clist->rlist.tex_x =(int)(clist->rlist.wall_hit_x * clist->tlist[clist->w_side].img_w);*/ } static void @@ -44,8 +48,10 @@ static void cl->rlist.sqy = (int16_t)cl->rlist.y_ray_pos; ft_detect(cl); if (cl->rlist.side == 0) + { cl->rlist.wall_dist = (cl->rlist.sqx - cl->rlist.x_ray_pos + (1 - cl->mlist->x_step) / 2) / cl->rlist.x_ray_dir; + } else cl->rlist.wall_dist = (cl->rlist.sqy - cl->rlist.y_ray_pos + (1 - cl->mlist->y_step) / 2) / cl->rlist.y_ray_dir; @@ -71,7 +77,6 @@ void cl->rlist.wall_b = wl->y_size - 1; ft_choose_tex(cl); ft_calc_tex(cl); - printf("%f\n", cl->rlist.wall_hit_x); ft_draw_verline(cl, i, cl->rlist.wall_t - 1, cl->rlist.wall_b); i++; } |