aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h1
-rw-r--r--map/map_one.cub12
-rw-r--r--src/ft_draw_sprite.c5
-rw-r--r--src/ft_sort_s_t.c37
5 files changed, 48 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 02e9b07..4e51445 100644
--- a/Makefile
+++ b/Makefile
@@ -129,6 +129,7 @@ SRCS_NAME += ft_draw_map_back.c
SRCS_NAME += ft_draw_ammo_back.c
SRCS_NAME += ft_draw_ammo_bar.c
SRCS_NAME += ft_shoot.c
+SRCS_NAME += ft_sort_s_t.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 25b80ee..2042297 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -89,6 +89,7 @@ int8_t ft_draw_verline(t_cub *cl, int32_t x,
int32_t y1, int32_t y2);
void ft_sprite_h_w(t_cub *cl, t_sprite *sprite);
void ft_sort_sprites(t_cub *cl, int16_t i, int16_t j);
+void ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]);
void ft_calc_sprite(t_cub *cl);
void ft_draw_sprite(t_cub *cl, t_sprite *sprite);
void ft_calc_trap(t_cub *cl);
diff --git a/map/map_one.cub b/map/map_one.cub
index b11ff6d..e7e5393 100644
--- a/map/map_one.cub
+++ b/map/map_one.cub
@@ -1,4 +1,4 @@
-R 1600 1000
+R 800 800
NO ./media/img/tex/wood_wall_1.xpm
SO ./media/img/tex/wood_wall_1.xpm
@@ -18,9 +18,9 @@ SH 2
1111111
111111111111000001
-100000000+00000301
-10000E000T00000301
-100000000000000301
+100000000+02340001
+10000E000T02340001
+100000000002340001
100100000+00000001
101100000111000001
111111111111110011
@@ -29,11 +29,11 @@ SH 2
1011001 100001
111101111111110111
10000000110101011
-12020202020000001
+10000000000000001
1#000000000000001
1@000000000000001
1!000000000000001
-12020202020000001
+10000000000000001
11000000110100011
11110111111101011
11111 1 1111
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c
index b381957..5c0fe41 100644
--- a/src/ft_draw_sprite.c
+++ b/src/ft_draw_sprite.c
@@ -41,9 +41,9 @@ void
{
float dist_tab[8][4096];
- while (++jt <= cl->mlist.sprite_var)
+ while (++jt < cl->mlist.sprite_var)
{
- while (++it <= cl->mlist.sprite_nbr[jt])
+ while (++it < cl->mlist.sprite_nbr[jt])
{
dist_tab[jt][it] =
((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) *
@@ -62,6 +62,7 @@ void
ft_sort_sprites_norme(dist_tab[jt], &it, jt, cl);
it = -1;
}
+ ft_sort_s_t(cl, dist_tab);
}
static void
diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c
new file mode 100644
index 0000000..f015abc
--- /dev/null
+++ b/src/ft_sort_s_t.c
@@ -0,0 +1,37 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_sort_s_t.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/24 20:22:45 by rbousset #+# #+# */
+/* Updated: 2020/03/09 18:56:01 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+/*clearpilled*/
+
+void
+ ft_sort_s_t(t_cub *cl, float dist_tab[8][4096])
+{
+ uint16_t i;
+ int32_t tmp;
+
+ i = 0;
+ while (i < cl->mlist.sprite_var)
+ {
+ if (dist_tab[i][0] < dist_tab[i + 1][0])
+ {
+ i = 0;
+ }
+ i++;
+ }
+}