aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_sprite.c
diff options
context:
space:
mode:
authorsalaaad2 <arthudurant263@gmail.com>2020-02-24 10:20:20 +0100
committersalaaad2 <arthudurant263@gmail.com>2020-02-24 10:20:20 +0100
commit9fc4434c0deac6a3537183266adb9e85f3883db8 (patch)
tree3c4a2e829da3aec0803ff9e8d7f7003ec82f596f /src/ft_draw_sprite.c
parentshpritz (diff)
download42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.gz
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.bz2
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.xz
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.tar.zst
42-cub3d-9fc4434c0deac6a3537183266adb9e85f3883db8.zip
tests
Diffstat (limited to '')
-rw-r--r--src/ft_draw_sprite.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c
index 38c1fd9..e7df49b 100644
--- a/src/ft_draw_sprite.c
+++ b/src/ft_draw_sprite.c
@@ -1,6 +1,7 @@
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -29,15 +30,18 @@ ft_draw_sprite(t_cub *cl, int x)
int d;
ver_it = cl->sp_list.s_start_x;
- while (ver_it < cl->sp_list.s_end_x)
+ ver_it = (ver_it < 0) ? -ver_it : ver_it ;
+ while (ver_it < cl->sp_list.s_end_x - 1)
{
tex_x = (int)(256 * (ver_it - (-cl->sp_list.s_w / 2 + cl->sp_list.s_screen_x)) * cl->tlist[4].img_w / cl->sp_list.s_w) / 256;
hor_it = cl->sp_list.s_start_y;
- while (hor_it < cl->sp_list.s_end_y)
+ while (hor_it < cl->sp_list.s_end_y - 1)
{
- d = hor_it * 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;
+ d = (hor_it) * 256 - cl->wlist->y_size * 128 + cl->sp_list.s_h * 128;
+ tex_y = ((d * cl->tlist[4].img_w) / cl->sp_list.s_h) / 256;
ft_draw_verline_sprite(cl, x, hor_it, tex_y);
+ hor_it++;
+ printf("hor_it : %d ver it : %d", hor_it, ver_it);
}
ver_it++;
}