diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_verline.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c index 0fad33a..6cbdc00 100644 --- a/src/ft_draw_verline.c +++ b/src/ft_draw_verline.c @@ -11,6 +11,7 @@ /* ************************************************************************** */ #include <cub3d.h> +#include <stdio.h> static void ft_draw_floor(t_cub *cl, int32_t y, int32_t x) @@ -38,29 +39,21 @@ static void } int8_t - ft_draw_verline(t_cub *cl, int32_t x, int32_t y1, int32_t y2) + ft_draw_verline(t_cub *cl, int32_t x, int32_t y, int32_t y2) { - int32_t y; - int32_t t; + int32_t d; + int32_t tex_y; - if (y1 < 0) - y1 = 0; - if (y2 < 0) - y2 = 0; - if ((uint32_t)y2 >= cl->wlist->y_size) - y2 = cl->wlist->x_size - 1; - if (y1 > y2) - { - t = y1; - y1 = y2; - y2 = t; - } - y = y1; + (y < 0) ? (y = 0) : 0; + (y2 < 0) ? (y2 = 0) : 0; ft_draw_ceil(cl, y, x); - ft_choose_tex(cl); - while (y <= y2) + while (y < y2) { - *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = (cl->rlist.side) ? 0x0000eeaa : 0x0000ffaa; + d = y * 256 - cl->wlist->y_size * 128 + cl->rlist.line_h * 128; + d = (d <= 0) ? (-d) : (d); + tex_y = ((d * cl->tlist[cl->w_side].img_h) / cl->rlist.line_h) / 256; + (tex_y < 0) ? (tex_y = 0) : 0; + ft_draw_texture(cl, x, y, tex_y); y++; } ft_draw_floor(cl, y, x); |