diff options
Diffstat (limited to '')
-rw-r--r-- | inc/cub3d.h | 43 | ||||
-rw-r--r-- | inc/cub3d_defines.h | 140 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 33 |
3 files changed, 138 insertions, 78 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h index d426bba..25b80ee 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -36,6 +36,7 @@ t_bmp_info ft_init_bmp_info(void); t_rgb ft_hex_to_og_rgb(uint32_t color); int8_t ft_init_sfx(t_cub *cl); int8_t ft_init_sprites(t_sprite ***sprites); +int8_t ft_init_weaps(t_sprite ***weaps); /* ** ====== HOOKS ====== @@ -62,8 +63,9 @@ void ft_death_hooks(t_win *wl, t_cub *cl); */ void ft_wall_tex_init(t_cub *cl); +void ft_next_sprite_init(t_cub *cl); void ft_weap_tex_init(t_cub *cl); -void ft_choose_tex(t_cub *clist); +void ft_num_tex_init(t_cub *cl); /* ** ====== DRAW ====== @@ -73,6 +75,12 @@ void ft_draw_square(int a, int b, int rgb, t_cub *clist); void ft_draw_map(char **map, t_cub *clist); void ft_draw_texture(t_cub *cl, int x, int y, int tex_y); int8_t ft_draw_hud(t_cub *clist); +void ft_draw_minimap_back(t_cub *cl); +void ft_draw_ammo_back(t_cub *cl); +void ft_draw_health_caption(t_cub *cl); +void ft_draw_ammo_caption(t_cub *cl); +void ft_draw_life_bar(t_cub *cl); +void ft_draw_ammo_bar(t_cub *cl); void ft_draw_scene(t_cub *clist); void ft_draw_scene_bmp(t_cub *clist); void ft_draw_circle(float a, float b, @@ -93,7 +101,6 @@ void ft_draw_skybox(t_cub *cl); void ft_draw_handweap(t_cub *cl); void ft_macos_suffer_animation(t_cub *cl); void ft_linux_suffer_animation(t_cub *cl); -void ft_draw_life_bar(t_cub *cl); /* ** ====== PARSING ====== @@ -134,23 +141,26 @@ int ft_get_map_core(int fd, t_cub *clist); void ft_get_topsp(char c, t_cub *clist); void ft_check_map_surrounds(t_map *ml, t_cub *cl); int ft_check_missing(t_cub *clist); +int ft_check_missing_tex_defines(t_cub *clist); +int ft_check_missing_sfx(t_cub *clist); int ft_missing_error(const char *err, t_cub *clist); int ft_map_error(const char *errmsg, t_cub *clist); size_t ft_get_line_len(char *line); +void ft_get_spawns(t_cub *cl); /* ** ====== ARGS ====== */ uint8_t ft_check_map_arg(int argc, const char *argv[]); -uint8_t ft_use_args(int argc, const char *argv[], - char *const envp[], t_cub *clist); +uint8_t ft_use_args(int argc, const char *argv[], t_cub *clist); /* ** ====== RAYCAST ====== */ void ft_castray(t_cub *cl); +void ft_choose_tex(t_cub *clist); void ft_detect(t_cub *cl); void ft_detection_init_x(t_cub *cl); void ft_detection_init_y(t_cub *cl); @@ -171,6 +181,9 @@ void ft_sfx_weapon_one_load(t_sfx *sfx); void ft_sfx_weapon_one_fire(t_sfx *sfx); void ft_sfx_weapon_two_load(t_sfx *sfx); void ft_sfx_weapon_two_fire(t_sfx *sfx); +void ft_sfx_weapon_three_load(t_sfx *sfx); +void ft_sfx_weapon_three_fire(t_sfx *sfx); +void ft_sfx_ooa(t_sfx *sfx); void *ft_sfx_death_thread(void *vargp); void *ft_sfx_footstep_thread(void *vargp); void *ft_sfx_new_lvl_thread(void *vargp); @@ -181,6 +194,21 @@ void *ft_sfx_weapon_one_load_thread(void *vargp); void *ft_sfx_weapon_one_fire_thread(void *vargp); void *ft_sfx_weapon_two_load_thread(void *vargp); void *ft_sfx_weapon_two_fire_thread(void *vargp); +void *ft_sfx_weapon_three_load_thread(void *vargp); +void *ft_sfx_weapon_three_fire_thread(void *vargp); +void *ft_sfx_ooa_thread(void *vargp); + +/* +** ====== DELETION ====== +*/ + +void ft_del_tex(t_cub *clist); +void ft_del_map(t_map *ml); +void ft_del_sprites_lists(t_cub *clist); +void ft_del_sfx_cmd(t_cub *clist); +uint8_t ft_free_words(char **words); +uint8_t ft_free_sprites_path(char **sprites); +int ft_exit(uint8_t exit_code, t_cub *clist); /* ** ====== OTHER ====== @@ -191,12 +219,8 @@ void ft_enable_music(t_cub *cl); void ft_music_fork(char **mcmd_words, char *const envp[]); int8_t ft_save_to_bmp(t_cub *cl); int ft_error(uint8_t retval, const char *errmsg, t_cub *clist); -uint8_t ft_free_words(char **words); -uint8_t ft_free_sprites(char **sprites); -void ft_del_extra_sprites(t_cub *cl); int8_t ft_warp_level(char *path, t_cub *cl); -int ft_exit(uint8_t exit_code, t_cub *clist); -uint32_t ft_rgb_to_hex(t_rgb rgb); +uint32_t ft_rgb_to_hex(float dist, t_rgb rgb, t_cub *cl); t_bmp_rgb ft_hex_to_rgb(uint32_t color); uint32_t ft_darken(t_rgb rgb, t_cub *cl); void ft_death_screen(t_cub *cl); @@ -204,6 +228,7 @@ void ft_get_fps_count(clock_t delta_time, t_cub *cl); void ft_find_item(t_player *pl, t_map *ml, t_cub *cl); int8_t ft_switch_weap_one(t_cub *cl); int8_t ft_switch_weap_two(t_cub *cl); +int8_t ft_switch_weap_three(t_cub *cl); void ft_shoot(t_cub *cl, uint16_t center); # endif diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index 01fa291..4ef2391 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -15,16 +15,18 @@ /* ** ====== RETURN VALUES ====== -*/ - -/* +** ** ret vals: +** --------- ** 1: no argv[1] -** 2: failed structs init -** 3: failed mlx init -** 4: map error -** 5: no map -** 6: read error +** 2: allocation error +** 3: failed structs init +** 4: failed mlx init +** 5: map error +** 6: no map +** 7: read error +** 8: bmp related error +** 9: missing some media files */ enum @@ -43,9 +45,7 @@ enum /* ** ====== OS ====== -*/ - -/* +** ** 1: Darwin ** 2: Linux */ @@ -72,6 +72,7 @@ enum # define FT_SPC_KEY 49 # define FT_ONE_KEY 18 # define FT_TWO_KEY 19 +# define FT_THREE_KEY 20 # else # define FT_W_KEY 119 # define FT_A_KEY 97 @@ -86,44 +87,54 @@ enum # define FT_SPC_KEY 32 # define FT_ONE_KEY 49 # define FT_TWO_KEY 50 +# define FT_THREE_KEY 51 # endif /* ** ====== NEEDED PATHS ====== */ -# define FT_SFX_DEATH_PATH "./media/sound/sfx/death_screen.wav" -# define FT_SFX_FS_ONE_PATH "./media/sound/sfx/footstep_one.wav" -# define FT_SFX_FS_TWO_PATH "./media/sound/sfx/footstep_two.wav" -# define FT_SFX_N_LVL_PATH "./media/sound/sfx/next_lvl.wav" -# define FT_SFX_SCR_ONE_PATH "./media/sound/sfx/scream_one.wav" -# define FT_SFX_SCR_TWO_PATH "./media/sound/sfx/scream_two.wav" -# define FT_SFX_TRAP_PATH "./media/sound/sfx/trap.wav" -# define FT_SFX_HEAL_PATH "./media/sound/sfx/heal.wav" -# define FT_SFX_W_ONE_LOAD_PATH "./media/sound/sfx/sword_load.wav" -# define FT_SFX_W_ONE_FIRE_PATH "./media/sound/sfx/sword_fire.wav" -# define FT_SFX_W_TWO_LOAD_PATH "./media/sound/sfx/colt_load.wav" -# define FT_SFX_W_TWO_FIRE_PATH "./media/sound/sfx/colt_fire.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/colt_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/colt_w.xpm" -# define FT_WEAPON_TWO_FIRE_PATH "./media/img/weapons/colt_w_fire.xpm" -# define FT_HEAL_PACK_PATH "./media/img/sprites/first_aid.xpm" -# define FT_ZER_PATH "./media/img/numbers/zero.xpm" -# define FT_ONE_PATH "./media/img/numbers/one.xpm" -# define FT_TWO_PATH "./media/img/numbers/two.xpm" -# define FT_THR_PATH "./media/img/numbers/three.xpm" -# define FT_FOU_PATH "./media/img/numbers/four.xpm" -# define FT_FIV_PATH "./media/img/numbers/five.xpm" -# define FT_SIX_PATH "./media/img/numbers/six.xpm" -# define FT_SEV_PATH "./media/img/numbers/seven.xpm" -# define FT_EIG_PATH "./media/img/numbers/eight.xpm" -# define FT_NIN_PATH "./media/img/numbers/nine.xpm" -# define FT_PER_PATH "./media/img/numbers/percent.xpm" +# define FT_SFX_DEATH_PATH "./media/sound/sfx/death_screen.wav" +# define FT_SFX_FS_ONE_PATH "./media/sound/sfx/footstep_one.wav" +# define FT_SFX_FS_TWO_PATH "./media/sound/sfx/footstep_two.wav" +# define FT_SFX_N_LVL_PATH "./media/sound/sfx/next_lvl.wav" +# define FT_SFX_SCR_ONE_PATH "./media/sound/sfx/scream_one.wav" +# define FT_SFX_SCR_TWO_PATH "./media/sound/sfx/scream_two.wav" +# define FT_SFX_TRAP_PATH "./media/sound/sfx/trap.wav" +# define FT_SFX_HEAL_PATH "./media/sound/sfx/heal.wav" +# define FT_SFX_W_ONE_LOAD_PATH "./media/sound/sfx/sword_load.wav" +# define FT_SFX_W_ONE_FIRE_PATH "./media/sound/sfx/sword_fire.wav" +# define FT_SFX_W_TWO_LOAD_PATH "./media/sound/sfx/colt_load.wav" +# define FT_SFX_W_TWO_FIRE_PATH "./media/sound/sfx/colt_fire.wav" +# define FT_SFX_W_THREE_LOAD_PATH "./media/sound/sfx/double_b_load.wav" +# define FT_SFX_W_THREE_FIRE_PATH "./media/sound/sfx/double_b_fire.wav" +# define FT_SFX_OOA_PATH "./media/sound/sfx/ooa.wav" +# define FT_DEATH_SCREEN_PATH "./media/img/screens/death_screen.xpm" +# define FT_HUD_BACK_PATH "./media/img/hud/hud_back.xpm" +# define FT_WEAPON_ONE_SPR_PATH "./media/img/weapons/sword_s.xpm" +# define FT_WEAPON_TWO_SPR_PATH "./media/img/weapons/colt_s.xpm" +# define FT_WEAPON_THREE_SPR_PATH "./media/img/weapons/double_b_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/colt_w.xpm" +# define FT_WEAPON_TWO_FIRE_PATH "./media/img/weapons/colt_w_fire.xpm" +# define FT_WEAPON_THREE_PATH "./media/img/weapons/double_b_w.xpm" +# define FT_WEAPON_THREE_FIRE_PATH "./media/img/weapons/double_b_w_fire.xpm" +# define FT_HEAL_PACK_PATH "./media/img/sprites/first_aid.xpm" +# define FT_ZER_PATH "./media/img/hud/zero.xpm" +# define FT_ONE_PATH "./media/img/hud/one.xpm" +# define FT_TWO_PATH "./media/img/hud/two.xpm" +# define FT_THR_PATH "./media/img/hud/three.xpm" +# define FT_FOU_PATH "./media/img/hud/four.xpm" +# define FT_FIV_PATH "./media/img/hud/five.xpm" +# define FT_SIX_PATH "./media/img/hud/six.xpm" +# define FT_SEV_PATH "./media/img/hud/seven.xpm" +# define FT_EIG_PATH "./media/img/hud/eight.xpm" +# define FT_NIN_PATH "./media/img/hud/nine.xpm" +# define FT_PER_PATH "./media/img/hud/percent.xpm" +# define FT_INF_PATH "./media/img/hud/infinite.xpm" +# define FT_CAP_HEALTH_PATH "./media/img/hud/health.xpm" +# define FT_CAP_AMMO_PATH "./media/img/hud/ammo.xpm" /* ** ====== SOUNDS ====== @@ -139,9 +150,9 @@ enum ** ====== MOVE SPEED ====== */ -# define FT_MOVE_SPEED 0.28 -# define FT_STRAFE_SPEED 0.28 -# define FT_ROT_SPEED 0.28 +# define FT_MOVE_SPEED 0.18 +# define FT_STRAFE_SPEED 0.15 +# define FT_ROT_SPEED 0.15 /* ** ====== COLLISION ====== @@ -162,14 +173,14 @@ enum */ # define FT_CHRST_VALID_PARSE "RNSEWFCLMT" -# define FT_CHRST_MAP_ENTRY "0123456789NSEWLT!@+ " +# define FT_CHRST_MAP_ENTRY "0123456789NSEWLT!@+# " # define FT_CHRST_SPRITES "23456789" # define FT_CHRST_SPAWN "NSEW" -# define FT_CHRST_MAP_NON_WALL "023456789NESWLT!@+" +# define FT_CHRST_MAP_NON_WALL "023456789NESWLT!@+#" # define FT_CHRST_COLLISION "123456789 " # define FT_CHRST_DETECT "1L" -# define FT_CHRST_ITEM "!@+" -# define FT_CHRST_WEAPONS "!@" +# define FT_CHRST_ITEM "!@+#" +# define FT_CHRST_WEAPONS "!@#" /* ** ====== BMP ====== @@ -224,6 +235,7 @@ enum # define FT_ERR_TOO_MUCH_TRAPS "too much traps, limit is 512" # define FT_ERR_TOO_MUCH_W_ONE "too much weapon one, limit is 1" # define FT_ERR_TOO_MUCH_W_TWO "too much weapon two, limit is 1" +# define FT_ERR_TOO_MUCH_W_THREE "too much weapon three, limit is 1" /* ** ====== MISSING ERROR MSG ====== @@ -252,25 +264,37 @@ enum # define FT_ERR_MISS_SFX_W_ONE_FIRE "weapon one fire sound effect" # define FT_ERR_MISS_SFX_W_TWO_LOAD "weapon two load sound effect" # define FT_ERR_MISS_SFX_W_TWO_FIRE "weapon two fire sound effect" +# define FT_ERR_MISS_SFX_W_THREE_LOAD "weapon three load sound effect" +# define FT_ERR_MISS_SFX_W_THREE_FIRE "weapon three fire sound effect" +# define FT_ERR_MISS_SFX_OOA "out of ammunitions sound effect" # define FT_ERR_MISS_DEATH_SCREEN "death screen image" # define FT_ERR_MISS_HUD_BACK "HUD background image" # define FT_ERR_MISS_HEAL_PACK "heal pack image" -# define FT_ERR_MISS_W_ONE "weapon one image" +# define FT_ERR_MISS_W_ONE "weapon one handed image" # 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 "weapon two handed 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" +# define FT_ERR_MISS_W_THREE "weapon three handed image" +# define FT_ERR_MISS_W_THREE_FIRE "weapon three shooting image" +# define FT_ERR_MISS_W_ONE_SPR "weapon one sprite image" +# define FT_ERR_MISS_W_TWO_SPR "weapon two sprite image" +# define FT_ERR_MISS_W_THREE_SPR "weapon three sprite image" # define FT_ERR_MISS_NUMBER "number image" +# define FT_ERR_MISS_H_CAPTION "health caption" +# define FT_ERR_MISS_A_CAPTION "ammo caption" /* ** ====== OTHER ====== */ # define FT_PARSE_END_RET 25 -# define FT_STRT_LIFE 200 -# define FT_TRAP_DAMAGE_AMOUNT 27 -# define FT_HEAL_PACK_AMOUNT 19 -# define FT_BOUNCE_FACTOR 8 +# define FT_STRT_LIFE 250 +# define FT_TRAP_DAMAGE_AMOUNT 45 +# define FT_HEAL_PACK_AMOUNT 20 +# define FT_BOUNCE_FACTOR 4 +# define FT_WEAP_ONE_STRT_AMMO -4 +# define FT_WEAP_TWO_STRT_AMMO 30 +# define FT_WEAP_THREE_STRT_AMMO 24 +# define FT_WEAP_MAX_AMMO 1000 # endif diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index f538c7e..809963c 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -133,8 +133,9 @@ typedef struct s_player float plane_y; uint8_t fire; int16_t life; - uint8_t has_weapon[2]; + uint8_t has_weapon[3]; int8_t handles_weapon; + int16_t ammo[3]; } t_player; typedef struct s_ray @@ -200,10 +201,10 @@ typedef struct s_map int32_t sprite_order[8][4096]; int32_t traps_nbr; int32_t heals_nbr; - int32_t weaps_nbr[2]; + int32_t weaps_nbr[3]; int32_t traps_order[512]; int32_t heals_order[64]; - int32_t weaps_order[2][1]; + int32_t weaps_order[3][1]; size_t line_chk; size_t map_start; uint8_t isspawn; @@ -214,9 +215,8 @@ typedef struct s_map uint8_t isskybox; uint8_t istraps; uint8_t isheals; - uint8_t isweapon[2]; uint8_t darklvl; - uint8_t scale; + uint16_t scale; int8_t topsp; uint32_t nlx; uint32_t nly; @@ -233,13 +233,24 @@ typedef struct s_cub uint8_t doicast; uint16_t currlvl; uint16_t i; - char *const *envp; char errmsg[64]; int32_t key_input[5]; char fps_count[9]; pthread_t mtid; int8_t isdead; uint8_t moves; + uint16_t map_back_h; + uint16_t map_back_w; + uint16_t amm_back_h; + uint16_t amm_back_w; + uint16_t life_cap_h; + uint16_t life_cap_w; + uint16_t life_num_h; + uint16_t life_num_w; + uint16_t ammo_cap_h; + uint16_t ammo_cap_w; + uint16_t ammo_num_h; + uint16_t ammo_num_w; int (*key_ptr[6])(struct s_cub*); int8_t (*get_ptr[14])(char**, struct s_cub*); char ref[22][3]; @@ -251,14 +262,14 @@ typedef struct s_cub struct s_img death_screen; struct s_rgb f_rgb; struct s_rgb c_rgb; - struct s_img tlist[20]; - struct s_img tweap[4]; - struct s_img tnum[11]; + struct s_img tlist[23]; + struct s_img tweap[6]; + struct s_img tnum[12]; struct s_sprite **sprites; struct s_sprite traps[512]; struct s_sprite heals[64]; - struct s_sprite weaps[2][1]; - struct s_sfx sfx[10]; + struct s_sprite **weaps; + struct s_sfx sfx[13]; } t_cub; # endif |