diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 18:13:59 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 18:13:59 +0100 |
commit | 78fb5c553758c748db7662d5f4388f52715e335c (patch) | |
tree | 3c89a485f45bf64e0f9a168a8118c3f605439815 /src | |
parent | Fixed (diff) | |
download | 42-cub3d-78fb5c553758c748db7662d5f4388f52715e335c.tar.gz 42-cub3d-78fb5c553758c748db7662d5f4388f52715e335c.tar.bz2 42-cub3d-78fb5c553758c748db7662d5f4388f52715e335c.tar.xz 42-cub3d-78fb5c553758c748db7662d5f4388f52715e335c.tar.zst 42-cub3d-78fb5c553758c748db7662d5f4388f52715e335c.zip |
Fixed sprite shadows
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_draw_textures.c | 19 | ||||
-rw-r--r-- | src/ft_floor_cast.c | 23 | ||||
-rw-r--r-- | src/ft_raycasting.c | 2 |
3 files changed, 18 insertions, 26 deletions
diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c index 4bc0b78..0724a6d 100644 --- a/src/ft_draw_textures.c +++ b/src/ft_draw_textures.c @@ -25,20 +25,17 @@ void ft_draw_texture(t_cub *cl, int x, int y, int tex_y) { - float dist; - t_rgb rgb; + float dist; + t_rgb rgb; if ((dist = cl->rlist.wall_dist) <= 0) dist = 0.0001; - rgb.b = - (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * - cl->tlist[cl->w_side].img_h * tex_y]; - rgb.g = - (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * - cl->tlist[cl->w_side].img_h * tex_y + 1]; - rgb.r = - (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * - cl->tlist[cl->w_side].img_h * tex_y + 2]; + rgb.b = (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x + * 4 + 4 * cl->tlist[cl->w_side].img_h * tex_y]; + rgb.g = (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x + * 4 + 4 * cl->tlist[cl->w_side].img_h * tex_y + 1]; + rgb.r = (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x + * 4 + 4 * cl->tlist[cl->w_side].img_h * tex_y + 2]; *(int*)(cl->img.ptr + ((uint16_t)x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(dist, rgb, cl); } diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c index 9166147..e9315ed 100644 --- a/src/ft_floor_cast.c +++ b/src/ft_floor_cast.c @@ -27,22 +27,17 @@ static void ft_draw_extra_tex(uint8_t tid, uint16_t y, uint16_t x, t_cub *cl) { float dist; - float calc; + t_rgb rgb; dist = (cl->rlist.row_dist > 0) ? (cl->rlist.row_dist) : (0.0001); - calc = (dist * 0.1 * cl->mlist.darklvl); - calc = (calc >= 255) ? (255) : (calc); - calc = (calc < 1) ? (1) : (calc); - calc = (cl->mlist.darklvl > 0) ? (calc) : (1); - *(cl->img.ptr + x * 4 + (cl->img.sizeline * y)) = - (uint8_t)*(cl->tlist[tid].ptr + cl->tlist[tid].tex_x * 4 + 4 * - cl->tlist[tid].img_w * cl->tlist[tid].tex_y) / calc; - *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 1) = - (uint8_t)*(cl->tlist[tid].ptr + cl->tlist[tid].tex_x * 4 + 4 * - cl->tlist[tid].img_w * cl->tlist[tid].tex_y + 1) / calc; - *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 2) = - (uint8_t)*(cl->tlist[tid].ptr + cl->tlist[tid].tex_x * 4 + 4 * - cl->tlist[tid].img_w * cl->tlist[tid].tex_y + 2) / calc; + rgb.b = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x + * 4 + 4 * cl->tlist[tid].img_h * cl->tlist[tid].tex_y]; + rgb.g = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x + * 4 + 4 * cl->tlist[tid].img_h * cl->tlist[tid].tex_y + 1]; + rgb.r = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x + * 4 + 4 * cl->tlist[tid].img_h * cl->tlist[tid].tex_y + 2]; + *(int*)(cl->img.ptr + ((uint16_t)x * 4 + + (y * cl->img.sizeline))) = ft_rgb_to_hex(dist, rgb, cl); } static void diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index e6c87ff..1a12c46 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -79,7 +79,6 @@ static void cl->rlist.wall_b = wl->y_size - 1; ft_choose_tex(cl); ft_calc_tex(cl); - ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); cl->rlist.wall_bz[i] = cl->rlist.wall_b; cl->rlist.wall_dist_tab[i] = cl->rlist.wall_dist; } @@ -99,6 +98,7 @@ void while (i < cl->wlist.x_size) { ft_castray_loop(i, &cl->wlist, cl); + ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); i++; } ft_floor_cast(cl); |