diff options
Diffstat (limited to '')
-rw-r--r-- | inc/cub3d_defines.h | 2 | ||||
-rw-r--r-- | map/map_one.cub | 6 | ||||
-rw-r--r-- | map/map_two.cub | 2 | ||||
-rw-r--r-- | src/ft_draw_sprite_extra.c | 44 | ||||
-rw-r--r-- | src/ft_get_sprite.c | 2 | ||||
-rw-r--r-- | src/ft_tex_init.c | 27 |
6 files changed, 52 insertions, 31 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index 6ab05c2..457f121 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -115,7 +115,7 @@ enum */ # define FT_CHRST_VALID_PARSE "RNSEWFCLMT" -# define FT_CHRST_MAP_ENTRY "012NSEWLT " +# define FT_CHRST_MAP_ENTRY "01234NSEWLT " # define FT_CHRST_SPAWN "NSEW" # define FT_CHRST_MAP_NON_WALL "02NESWLT" # define FT_CHRST_COLLISION "12 " diff --git a/map/map_one.cub b/map/map_one.cub index b0eedb0..29315e3 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -13,16 +13,10 @@ T ./media/img/spikes.xpm SH 4 111111111111111111 -<<<<<<< HEAD 100000000002000001 100000030002000001 100100000004000201 -1011000N0111000001 -======= -120000000011000001 -100100000000000201 101100000111000001 ->>>>>>> master 111111111111110011 1000001 100001 1001001 100001 diff --git a/map/map_two.cub b/map/map_two.cub index 309485b..8e4607f 100644 --- a/map/map_two.cub +++ b/map/map_two.cub @@ -14,7 +14,7 @@ F ./media/img/arrow2.xpm 100000000000000000000000000000000001 100000000000030000000000000000000001 100000000000000000000000000000000001 -10000000000002222222200W000000000001 +10000000000002020202000W000000000001 100000000000000000000000000000000001 100000000000040000000000000000000001 100000000000000000000000000000000001 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 |