diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | inc/cub3d.h | 3 | ||||
-rw-r--r-- | inc/cub3d_defines.h | 4 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 3 | ||||
-rw-r--r-- | src/ft_check_missing.c | 12 | ||||
-rw-r--r-- | src/ft_tex_init.c | 49 | ||||
-rw-r--r-- | src/ft_tex_weap_init.c | 46 | ||||
-rw-r--r-- | src/ft_warp_level.c | 1 | ||||
-rw-r--r-- | src/main.c | 1 |
9 files changed, 95 insertions, 25 deletions
@@ -105,6 +105,7 @@ SRCS_NAME += ft_get_heal_spawn.c SRCS_NAME += ft_draw_heals.c SRCS_NAME += ft_draw_heals_extra.c SRCS_NAME += ft_find_item.c +SRCS_NAME += ft_tex_weap_init.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# diff --git a/inc/cub3d.h b/inc/cub3d.h index fa42b4f..aedd550 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -61,7 +61,8 @@ void ft_death_hooks(t_win *wl, t_cub *cl); ** ====== TEXTURES ====== */ -void ft_wall_tex_init(t_cub *clist); +void ft_wall_tex_init(t_cub *cl); +void ft_weap_tex_init(t_cub *cl); void ft_choose_tex(t_cub *clist); /* diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index f5824ce..8a435f2 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -95,6 +95,8 @@ enum # define FT_SFX_TRAP_PATH "./media/sound/sfx/trap.wav" # define FT_DEATH_SCREEN_PATH "./media/img/screens/death_screen.xpm" # define FT_HUD_BACK_PATH "./media/img/tex/plate_small.xpm" +# define FT_WEAPON_ONE_SPR_PATH "./media/img/sprites/sword_s.xpm" +# define FT_WEAPON_TWO_SPR_PATH "./media/img/sprites/sword_s.xpm" # define FT_WEAPON_ONE_PATH "./media/img/weapons/sword_w.xpm" # define FT_WEAPON_ONE_FIRE_PATH "./media/img/weapons/sword_w_fire.xpm" # define FT_WEAPON_TWO_PATH "./media/img/weapons/sword_w.xpm" @@ -227,6 +229,8 @@ enum # define FT_ERR_MISS_W_ONE_FIRE "weapon one shooting image" # define FT_ERR_MISS_W_TWO "weapon two image" # define FT_ERR_MISS_W_TWO_FIRE "weapon two shooting image" +# define FT_ERR_MISS_W_ONE_SPR "weapon one image" +# define FT_ERR_MISS_W_TWO_SPR "weapon one image" /* ** ====== OTHER ====== diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index fc3eead..332ced4 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -253,7 +253,8 @@ typedef struct s_cub struct s_img death_screen; struct s_rgb f_rgb; struct s_rgb c_rgb; - struct s_img tlist[18]; + struct s_img tlist[20]; + struct s_img tweap[4]; struct s_sprite **sprites; struct s_sprite traps[512]; struct s_sprite heals[64]; diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c index fcebf3f..4b4a3ef 100644 --- a/src/ft_check_missing.c +++ b/src/ft_check_missing.c @@ -40,6 +40,15 @@ static int { int8_t i; + if (ft_check_not_found(FT_WEAPON_ONE_SPR_PATH) < 0 || + ft_check_ext(FT_WEAPON_ONE_SPR_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_W_ONE_SPR, clist)); + if (ft_check_not_found(FT_WEAPON_TWO_SPR_PATH) < 0 || + ft_check_ext(FT_WEAPON_TWO_SPR_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_W_TWO_SPR, clist)); + if (ft_check_not_found(FT_HEAL_PACK_PATH) < 0 || + ft_check_ext(FT_HEAL_PACK_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_HEAL_PACK, clist)); i = 0; while ((i + 2) <= clist->mlist.topsp) { @@ -71,9 +80,6 @@ static int if (ft_check_not_found(FT_WEAPON_TWO_FIRE_PATH) < 0 || ft_check_ext(FT_WEAPON_TWO_FIRE_PATH, ".xpm") < 0) return (ft_missing_error(FT_ERR_MISS_W_TWO_FIRE, clist)); - if (ft_check_not_found(FT_HEAL_PACK_PATH) < 0 || - ft_check_ext(FT_HEAL_PACK_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_HEAL_PACK, clist)); return (ft_check_missing_sprites(clist)); } diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c index 6486e87..34f9fb9 100644 --- a/src/ft_tex_init.c +++ b/src/ft_tex_init.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_basic_keys.c :+: :+: :+: */ +/* ft_tex_init.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fmoenne- <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ @@ -13,30 +13,31 @@ #include <libft.h> #include <cub3d.h> #include <stdint.h> -#include <stdio.h> #include <mlx.h> /* ** tlist[] index summary ** --------------------- -** 0 : no -** 1 : so -** 2 : ea -** 3 : we -** 4 : sprite 2 -** 5 : new level door -** 6 : floor -** 7 : ceil / skybox -** 8 : sprite 3 -** 9 : sprite 4 -** 10 : sprite 5 -** 11 : sprite 6 -** 12 : sprite 7 -** 13 : sprite 8 -** 14 : sprite 9 -** 15 : trap -** 16 : HUD back -** 17 : heal pack +** 0: no +** 1: so +** 2: ea +** 3: we +** 4: sprite 2 +** 5: new level door +** 6: floor +** 7: ceil / skybox +** 8: sprite 3 +** 9: sprite 4 +** 10: sprite 5 +** 11: sprite 6 +** 12: sprite 7 +** 13: sprite 8 +** 14: sprite 9 +** 15: trap +** 16: HUD back +** 17: heal pack +** 18: weapon one sprite +** 19: weapon two sprite */ static void @@ -78,6 +79,14 @@ static void FT_HUD_BACK_PATH, &cl->tlist[16].img_w, &cl->tlist[16].img_h); cl->tlist[16].ptr = mlx_get_data_addr(cl->tlist[16].img, &cl->tlist[16].bpp, &cl->tlist[16].sizeline, &cl->tlist[16].endian); + cl->tlist[18].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_WEAPON_ONE_SPR_PATH, &cl->tlist[18].img_w, &cl->tlist[18].img_h); + cl->tlist[18].ptr = mlx_get_data_addr(cl->tlist[18].img, + &cl->tlist[18].bpp, &cl->tlist[18].sizeline, &cl->tlist[18].endian); + cl->tlist[19].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_WEAPON_TWO_SPR_PATH, &cl->tlist[19].img_w, &cl->tlist[19].img_h); + cl->tlist[19].ptr = mlx_get_data_addr(cl->tlist[19].img, + &cl->tlist[19].bpp, &cl->tlist[19].sizeline, &cl->tlist[19].endian); cl->walltexgood = 1; if (cl->mlist.sprite_var > 1) ft_next_sprite_init(cl); diff --git a/src/ft_tex_weap_init.c b/src/ft_tex_weap_init.c new file mode 100644 index 0000000..ac78de9 --- /dev/null +++ b/src/ft_tex_weap_init.c @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_tex_weap_init.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: fmoenne- <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:43:55 by fmoenne- #+# #+# */ +/* Updated: 2020/02/14 17:43:56 by fmoenne- ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <stdint.h> +#include <stdio.h> +#include <mlx.h> + +/* +** tweap[] index summary +** 0: weapon one +** 1: weapon one fire +** 2: weapon two +** 3: weapon two fire +*/ + +void + ft_weap_tex_init(t_cub *cl) +{ + cl->tweap[0].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_WEAPON_ONE_PATH, &cl->tweap[0].img_w, &cl->tweap[0].img_h); + cl->tweap[0].ptr = mlx_get_data_addr(cl->tweap[0].img, + &cl->tweap[0].bpp, &cl->tweap[0].sizeline, &cl->tweap[0].endian); + cl->tweap[1].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_WEAPON_ONE_FIRE_PATH, &cl->tweap[1].img_w, &cl->tweap[1].img_h); + cl->tweap[1].ptr = mlx_get_data_addr(cl->tweap[1].img, + &cl->tweap[1].bpp, &cl->tweap[1].sizeline, &cl->tweap[1].endian); + cl->tweap[2].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_WEAPON_TWO_PATH, &cl->tweap[2].img_w, &cl->tweap[2].img_h); + cl->tweap[2].ptr = mlx_get_data_addr(cl->tweap[2].img, + &cl->tweap[2].bpp, &cl->tweap[2].sizeline, &cl->tweap[2].endian); + cl->tweap[3].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_WEAPON_TWO_FIRE_PATH, &cl->tweap[3].img_w, &cl->tweap[3].img_h); + cl->tweap[3].ptr = mlx_get_data_addr(cl->tweap[3].img, + &cl->tweap[3].bpp, &cl->tweap[3].sizeline, &cl->tweap[3].endian); +} diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index a2b6006..09f0322 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -116,6 +116,7 @@ int8_t if (isoldmus) ft_memdel((void*)&tmp_mup); ft_wall_tex_init(cl); + ft_weap_tex_init(cl); ft_memdel((void*)&next_path); return (0); } @@ -30,6 +30,7 @@ int if (ft_init_winlx(clist) < 0) return (ft_exit(FT_RET_FAILED_MLX, clist)); ft_wall_tex_init(clist); + ft_weap_tex_init(clist); ft_use_args(argc, argv, envp, clist); return (FT_RET_FINE); } |