diff options
Diffstat (limited to 'src/ft_draw_textures.c')
-rw-r--r-- | src/ft_draw_textures.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c index dcd36e7..0724a6d 100644 --- a/src/ft_draw_textures.c +++ b/src/ft_draw_textures.c @@ -22,28 +22,26 @@ ** 4 : sprite */ -void ft_draw_texture(t_cub *cl, int x, int y, int tex_y) +void + ft_draw_texture(t_cub *cl, int x, int y, int tex_y) { - float dist; - float calc; + float dist; + t_rgb rgb; if ((dist = cl->rlist.wall_dist) <= 0) dist = 0.0001; - calc = (dist * 0.1 * cl->mlist.darklvl); - calc = (calc >= 255) ? (255) : (calc); - calc = (calc < 1) ? (1) : (calc); - cl->img.ptr[x * 4 + (cl->img.sizeline * y)] = - (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] / calc; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 1] = - (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] / calc; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 2] = - (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] / calc; + 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); } -void ft_choose_tex(t_cub *clist) +void + ft_choose_tex(t_cub *clist) { if (clist->rlist.sqy == clist->mlist.nlx && clist->rlist.sqx == clist->mlist.nly) |