aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_draw_sprite_extra.c44
-rw-r--r--src/ft_get_sprite.c2
-rw-r--r--src/ft_tex_init.c27
3 files changed, 50 insertions, 23 deletions
diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c
index f695896..c1fa4aa 100644
--- a/src/ft_draw_sprite_extra.c
+++ b/src/ft_draw_sprite_extra.c
@@ -51,28 +51,28 @@ void
i = 0;
j = 0;
while (j < 3)
- {
- while (i < cl->mlist.sprite_nbr)
{
- sprite = cl->sprites[j][i];
- sprite.current_sprite = (j == 0) ? 4 : j + 7;
- printf("%d\n", j);
- sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5);
- sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5);
- sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y
- - cl->plist.dir_x * cl->plist.plane_y);
- sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex
- - cl->plist.dir_x * sprite.spritey);
- sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex
- + cl->plist.plane_x * sprite.spritey);
- sprite.spritescreenx = (int)(cl->wlist.x_size / 2) *
- (1 + sprite.transformx / sprite.transformy);
- ft_sprite_height(cl, &sprite);
- ft_sprite_width(cl, &sprite);
- ft_draw_sprite(cl, &sprite);
- i++;
+ while (i < cl->mlist.sprite_nbr)
+ {
+ sprite = cl->sprites[j][i];
+ sprite.current_sprite = (j == 0) ? 4 : j + 7;
+ /* printf("%d\n", sprite.current_sprite); */
+ sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5);
+ sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5);
+ sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y
+ - cl->plist.dir_x * cl->plist.plane_y);
+ sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex
+ - cl->plist.dir_x * sprite.spritey);
+ sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex
+ + cl->plist.plane_x * sprite.spritey);
+ sprite.spritescreenx = (int)(cl->wlist.x_size / 2) *
+ (1 + sprite.transformx / sprite.transformy);
+ ft_sprite_height(cl, &sprite);
+ ft_sprite_width(cl, &sprite);
+ ft_draw_sprite(cl, &sprite);
+ i++;
+ }
+ i = 0;
+ j++;
}
- i = 0;
- j++;
- }
}
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c
index c288b67..68c4f75 100644
--- a/src/ft_get_sprite.c
+++ b/src/ft_get_sprite.c
@@ -25,7 +25,6 @@ void
x = 1;
y = 1;
i = 0;
- clist->mlist.sprite_var++;
while (clist->mlist.map[y])
{
while (clist->mlist.map[y][x])
@@ -43,6 +42,7 @@ void
x = 1;
y++;
}
+ clist->mlist.sprite_var += (clist->sprites[s_n][i].s_pos_x != 0);
}
void
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c
index 30b738e..1a2ac76 100644
--- a/src/ft_tex_init.c
+++ b/src/ft_tex_init.c
@@ -13,6 +13,7 @@
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
+#include <stdio.h>
#include <mlx.h>
/*
@@ -35,6 +36,28 @@
*/
static void
+ ft_next_sprite_init(t_cub *cl)
+{
+ uint16_t i;
+
+ i = 8;
+ while (i < cl->mlist.sprite_var + 7)
+ {
+ cl->tlist[i].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ "./media/img/hey.xpm", &cl->tlist[i].img_w, &cl->tlist[i].img_h);
+ cl->tlist[i].ptr = mlx_get_data_addr(cl->tlist[i].img,
+ &cl->tlist[i].bpp, &cl->tlist[i].sizeline, &cl->tlist[i].endian);
+ i++;
+ printf("%d\n", i );
+ cl->tlist[i].img = mlx_xpm_file_to_image(cl->wlist.wlx,
+ "./media/img/crapaud.xpm", &cl->tlist[i].img_w, &cl->tlist[i].img_h);
+ cl->tlist[i].ptr = mlx_get_data_addr(cl->tlist[i].img,
+ &cl->tlist[i].bpp, &cl->tlist[i].sizeline, &cl->tlist[i].endian);
+ i++;
+ }
+}
+
+static void
ft_wall_tex_init_norme_bis(t_cub *cl)
{
if (cl->mlist.isctex)
@@ -52,6 +75,10 @@ static void
&cl->tlist[7].bpp, &cl->tlist[7].sizeline, &cl->tlist[7].endian);
}
cl->walltexgood = 1;
+ if (cl->mlist.sprite_var > 1)
+ {
+ ft_next_sprite_init(cl);
+ }
}
static void