From 78fb5c553758c748db7662d5f4388f52715e335c Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 23 Mar 2020 18:13:59 +0100 Subject: Fixed sprite shadows --- src/ft_floor_cast.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/ft_floor_cast.c') 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 -- cgit v1.2.3