diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2020-02-19 16:34:13 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2020-02-19 16:34:13 +0100 |
commit | 01ce065c54d205b1d8432eebfa350f57e6f6c3a8 (patch) | |
tree | b2e7cd17c26595d2f2bbd71be3291f455a5cfdcb /src | |
parent | okok (diff) | |
download | 42-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')
-rw-r--r-- | src/ft_draw_textures.c | 19 | ||||
-rw-r--r-- | src/ft_draw_verline.c | 31 | ||||
-rw-r--r-- | src/ft_raycasting.c | 4 |
3 files changed, 10 insertions, 44 deletions
diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c index 942e386..25a6863 100644 --- a/src/ft_draw_textures.c +++ b/src/ft_draw_textures.c @@ -25,25 +25,6 @@ void ft_draw_texture(t_cub *cl, int x, int y, int tex_y) { - /* t_rgb rgb; */ - /*printf("%c\n", cl->img.ptr[x * 4 + 4 * (cl->img.sizeline * y)] );*/ - /**(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = (cl->rlist.side) ? 0x2200ffaa : 0x0000ffaa;*/ - /* ft_printf("DATA {{{{{%hd}}}}}\nW_SIDE> %d\n\n\n", */ - /* (int16_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] */ - /* , cl->w_side); */ - /* rgb.r = */ - /* (int8_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 = */ - /* (int8_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.b = */ - /* (int8_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 + (x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(rgb); */ - - cl->img.ptr[x * 4 + (cl->img.sizeline * y)] = (char)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * cl->tlist[cl->w_side].img_h * tex_y]; 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); diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 3e658e3..394d6dc 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -26,7 +26,7 @@ void clist->rlist.wall_dist * clist->rlist.x_ray_dir; clist->rlist.wall_hit_x -= floor(clist->rlist.wall_hit_x); clist->tlist[clist->w_side].tex_x = (int)(clist->rlist.wall_hit_x * - (double)clist->tlist[clist->w_side].img_w); + (double)clist->tlist[clist->w_side].img_w); if (clist->rlist.side == 0 && clist->rlist.x_ray_dir > 0) clist->tlist[clist->w_side].tex_x = clist->tlist[clist->w_side].img_w - clist->tlist[clist->w_side].tex_x - 1; @@ -83,7 +83,7 @@ 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 - 1, cl->rlist.wall_b); + ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); i++; } } |