aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_verline.c
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2020-02-19 16:34:13 +0100
committersalaaad2 <arthurdurant263@gmail.com>2020-02-19 16:34:13 +0100
commit01ce065c54d205b1d8432eebfa350f57e6f6c3a8 (patch)
treeb2e7cd17c26595d2f2bbd71be3291f455a5cfdcb /src/ft_draw_verline.c
parentokok (diff)
download42-cub3d-01ce065c54d205b1d8432eebfa350f57e6f6c3a8.tar.gz
42-cub3d-01ce065c54d205b1d8432eebfa350f57e6f6c3a8.tar.bz2
42-cub3d-01ce065c54d205b1d8432eebfa350f57e6f6c3a8.tar.xz
42-cub3d-01ce065c54d205b1d8432eebfa350f57e6f6c3a8.tar.zst
42-cub3d-01ce065c54d205b1d8432eebfa350f57e6f6c3a8.zip
yes :^) !
Diffstat (limited to 'src/ft_draw_verline.c')
-rw-r--r--src/ft_draw_verline.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/ft_draw_verline.c b/src/ft_draw_verline.c
index 65958ca..6cbdc00 100644
--- a/src/ft_draw_verline.c
+++ b/src/ft_draw_verline.c
@@ -39,36 +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)
{
d = y * 256 - cl->wlist->y_size * 128 + cl->rlist.line_h * 128;
- (d <= 0) ? (d = 1) : 0;
- /* printf("y : %d\ny_size : %d\nd : %d\nline_h : %d\n", y1, cl->wlist->y_size, d, cl->rlist.line_h); */
- cl->tlist[cl->w_side].tex_y = ((d * cl->tlist[cl->w_side].img_w) / cl->rlist.line_h) / 256;
- /*printf("w_side : %d\nd : %d\ntex_y : %d\n", cl->w_side, d, cl->tlist[cl->w_side].tex_y);*/
- ft_draw_texture(cl, x, y, cl->tlist[cl->w_side].tex_y);
- /* (int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = (cl->rlist.side) ? 0x2200ffaa : 0x0000ffaa; */
+ 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);