diff options
author | salaaad2 <arthudurant263@gmail.com> | 2020-02-24 22:20:33 +0100 |
---|---|---|
committer | salaaad2 <arthudurant263@gmail.com> | 2020-02-24 22:20:33 +0100 |
commit | fe145d4c59886b857b0966f8e9b673cfacc0695f (patch) | |
tree | 6f613a668ecd532d185b4b31d7b5fe8122d271de /src/ft_draw_sprite.c | |
parent | Norme (diff) | |
download | 42-cub3d-fe145d4c59886b857b0966f8e9b673cfacc0695f.tar.gz 42-cub3d-fe145d4c59886b857b0966f8e9b673cfacc0695f.tar.bz2 42-cub3d-fe145d4c59886b857b0966f8e9b673cfacc0695f.tar.xz 42-cub3d-fe145d4c59886b857b0966f8e9b673cfacc0695f.tar.zst 42-cub3d-fe145d4c59886b857b0966f8e9b673cfacc0695f.zip |
found 2 infinit loops hehe
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_sprite.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 9cd7dae..a3371b4 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -16,38 +16,41 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> - +/* void ft_draw_verline_sprite(t_cub *cl, int x, int y, int tex_y) { if (cl->tlist[4].tex_x) - cl->img.ptr[x * 4 + (cl->img.sizeline * y)] = - (char)cl->tlist[4].ptr[cl->tlist[4].tex_x * 4 + 4 * - cl->tlist[4].img_h * tex_y]; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 1] = - (char)cl->tlist[4].ptr[cl->tlist[4].tex_x * 4 + 4 * - cl->tlist[4].img_h * tex_y + 1]; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 2] = - (char)cl->tlist[4].ptr[cl->tlist[4].tex_x * 4 + 4 * - cl->tlist[4].img_h * tex_y + 2]; - cl->img.ptr[x * 4 + cl->wlist->x_size * y + 3] = (char)0; } - +*/ void - ft_draw_sprite(t_cub *cl, int x) + ft_draw_sprite(t_cub *cl) { - int hor_it; + int itx; + int ity; int d; + int tex_x; int tex_y; - hor_it = cl->sp_list.s_start_y; - while (hor_it < cl->sp_list.s_end_y) + itx = cl->sp_list.s_start_x; + while (itx < cl->sp_list.s_end_x) { - d = hor_it * 256 - cl->wlist->y_size * 128 + cl->rlist.line_h * 128; - d = (d <= 0) ? (-d) : (d); - tex_y = ((d * cl->tlist[4].img_h) / cl->rlist.line_h) / 256; - (tex_y < 0) ? (tex_y = 0) : 0; - ft_draw_verline_sprite(cl, x, hor_it, tex_y); - hor_it++; + tex_x = (int)((itx - (-cl->sp_list.s_w / 2 + cl->sp_list.s_screen_x)) + * cl->tlist[4].img_w / cl->sp_list.s_w); + ity = cl->sp_list.s_start_y; + while (ity < cl->sp_list.s_end_y) + { + d = ity * 256 - cl->wlist->y_size * 128 + cl->sp_list.s_h * 128; + tex_y = ((d * cl->tlist[4].img_h) / cl->sp_list.s_h) / 256; + if (*(cl->tlist[4].ptr + tex_x + tex_y * cl->tlist[4].sizeline / 4)) + { + /*cl->img.ptr[tex_x * 4 + (cl->img.sizeline * tex_y)] =*/ + /*(char)cl->tlist[4].ptr[cl->tlist[4].tex_x * 4 + 4 **/ + /*cl->tlist[4].img_h * tex_y];*/ + /*puts("qwe");*/ + } + ity++; + } + itx++; } } |