diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 22:40:47 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 22:40:47 +0100 |
commit | 3520f4bf3d435991f402e46731c15838baae0894 (patch) | |
tree | c8cbf06ebd69a422cbcf2cb8381916af172da726 /inc | |
parent | Still sfx to do (diff) | |
parent | Bug fix (diff) | |
download | 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.gz 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.bz2 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.xz 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.tar.zst 42-cub3d-3520f4bf3d435991f402e46731c15838baae0894.zip |
Merge branch 'master' into weaps
Diffstat (limited to 'inc')
-rw-r--r-- | inc/cub3d.h | 8 | ||||
-rw-r--r-- | inc/cub3d_defines.h | 129 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 12 |
3 files changed, 82 insertions, 67 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h index 61c4f01..84ce976 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -78,12 +78,14 @@ void ft_draw_circle(float a, float b, int32_t color, t_cub *cl); int8_t ft_draw_verline(t_cub *cl, int32_t x, int32_t y1, int32_t y2); -void ft_sprite_width(t_cub *cl, t_sprite *sprite); -void ft_sprite_height(t_cub *cl, t_sprite *sprite); +void ft_sprite_h_w(t_cub *cl, t_sprite *sprite); +void ft_sort_sprites(t_cub *cl); void ft_calc_sprite(t_cub *cl); void ft_draw_sprite(t_cub *cl, t_sprite *sprite); void ft_calc_trap(t_cub *cl); void ft_draw_traps(t_cub *cl, t_sprite *sprite); +void ft_calc_heal(t_cub *cl); +void ft_draw_heals(t_cub *cl, t_sprite *sprite); void ft_draw_skybox(t_cub *cl); void ft_macos_suffer_animation(t_cub *cl); void ft_linux_suffer_animation(t_cub *cl); @@ -118,6 +120,7 @@ size_t ft_get_map_h(char **map); size_t ft_get_map_w(char **map); void ft_get_sprite_spawn(t_cub *clist); void ft_get_trap_spawn(t_cub *clist); +void ft_get_heal_spawn(t_cub *clist); int8_t ft_check_map_line(char *line, uint8_t l, t_cub *clist); int8_t ft_check_ext(const char *filep, const char *ext); int8_t ft_check_not_found(const char *path); @@ -181,5 +184,6 @@ 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); 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); # endif diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index 1fb5c40..c4c3a13 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -16,6 +16,17 @@ /* ** ====== 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 +*/ + enum { FT_RET_FINE, @@ -31,16 +42,6 @@ enum } retvals; /* -** ret vals: -** 1: no argv[1] -** 2: failed structs init -** 3: failed mlx init -** 4: map error -** 5: no map -** 6: read error -*/ - -/* ** ====== OS ====== */ @@ -67,7 +68,7 @@ enum # define FT_F1_KEY 122 # define FT_TAB_KEY 48 # define FT_ESC_KEY 53 -/* TODO macOS return key */ +/* TODO: macOS return key */ # else # define FT_W_KEY 119 # define FT_A_KEY 97 @@ -98,6 +99,7 @@ enum # define FT_WEAPON_ONE_FIRE_PATH "./media/img/weapons/sword_w_fire.xpm" # define FT_WEAPON_TWO_PATH "./media/img/weapons/sword_w.xpm" # define FT_WEAPON_TWO_FIRE_PATH "./media/img/weapons/sword_w_fire.xpm" +# define FT_HEAL_PACK_PATH "./media/img/sprites/first_aid.xpm" /* ** ====== SOUNDS ====== @@ -136,12 +138,13 @@ 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 "+!@" /* ** ====== BMP ====== @@ -155,43 +158,45 @@ enum ** ====== MAP ERROR MSG ====== */ -# define FT_ERR_ALLOCATE "Allocation error" -# define FT_ERR_READ "read error" -# define FT_ERR_ARGS "too many or to few arguments" -# define FT_ERR_ARGV "Bad arguments" -# define FT_ERR_RES_SMALL "resolution is too small, 50x50 minimum pls" -# define FT_ERR_RES_ALPHA "resolution should be digits only" -# define FT_ERR_SH_ALPHA "shadow amount should be digits only" -# define FT_ERR_SH_RANGE "shadow should be set between 0 - 20" -# define FT_ERR_NOT_A_CUB "given map is not a .cub" -# define FT_ERR_NOT_A_XPM "given texture is not a .xpm" -# define FT_ERR_NOT_A_WAV "given sound file is not a .wav" -# define FT_ERR_COLOR_ALPHA "colors should be digits only" -# define FT_ERR_COLOR_MAX "colors should be maximum 255" -# define FT_ERR_COLOR_ARGS "colors should be three numbers with commas" -# define FT_ERR_SPRITE_DUMB "bad sprite order" -# define FT_ERR_UNFINISHED "no map" -# define FT_ERR_MAP_LEN "map length inconsistency" -# define FT_ERR_ILL_ENTRY "illegal map entry" -# define FT_ERR_ALR_SET "duplicate entry" -# define FT_ERR_ILL_MAP "map contains illegal char" -# define FT_ERR_MULT_SPAWN "multiple spawn points" -# define FT_ERR_MULT_NLVL "multiple spawn new level access points" -# define FT_ERR_NO_MAP "No map" -# define FT_ERR_MAP_WALLS "bad space or map is not surrounded by walls" -# define FT_ERR_MAP_EMPL "empty line in map" -# define FT_ERR_MAP_L_L "last line is invalid" -# define FT_ERR_RD_NO "could not find north side texture file" -# define FT_ERR_RD_SO "could not find south side texture file" -# define FT_ERR_RD_EA "could not find east side texture file" -# define FT_ERR_RD_WE "could not find west side texture file" -# define FT_ERR_RD_SP "could not find sprite texture file" -# define FT_ERR_RD_SB "could not find skybox file" -# define FT_ERR_RD_NL_TEX "could not find next level texture file" -# define FT_ERR_RD_NL_MAP "could not find next level map file" -# define FT_ERR_RD_MUSIC "could not find music file" -# define FT_ERR_RD_TRAP "could not find trap texture file" -# define FT_ERR_WR_BMP "could not export to bmp" +# define FT_ERR_ALLOCATE "Allocation error" +# define FT_ERR_READ "read error" +# define FT_ERR_ARGS "too many or to few arguments" +# define FT_ERR_ARGV "Bad arguments" +# define FT_ERR_RES_SMALL "resolution is too small, 50x50 minimum pls" +# define FT_ERR_RES_ALPHA "resolution should be digits only" +# define FT_ERR_SH_ALPHA "shadow amount should be digits only" +# define FT_ERR_SH_RANGE "shadow should be set between 0 - 20" +# define FT_ERR_NOT_A_CUB "given map is not a .cub" +# define FT_ERR_NOT_A_XPM "given texture is not a .xpm" +# define FT_ERR_NOT_A_WAV "given sound file is not a .wav" +# define FT_ERR_COLOR_ALPHA "colors should be digits only" +# define FT_ERR_COLOR_MAX "colors should be maximum 255" +# define FT_ERR_COLOR_ARGS "colors should be three numbers with commas" +# define FT_ERR_SPRITE_DUMB "bad sprite order" +# define FT_ERR_UNFINISHED "no map" +# define FT_ERR_MAP_LEN "map length inconsistency" +# define FT_ERR_ILL_ENTRY "illegal map entry" +# define FT_ERR_ALR_SET "duplicate entry" +# define FT_ERR_ILL_MAP "map contains illegal char" +# define FT_ERR_MULT_SPAWN "multiple spawn points" +# define FT_ERR_MULT_NLVL "multiple spawn new level access points" +# define FT_ERR_NO_MAP "No map" +# define FT_ERR_MAP_WALLS "bad space or map is not surrounded by walls" +# define FT_ERR_MAP_EMPL "empty line in map" +# define FT_ERR_MAP_L_L "last line is invalid" +# define FT_ERR_RD_NO "could not find north side texture file" +# define FT_ERR_RD_SO "could not find south side texture file" +# define FT_ERR_RD_EA "could not find east side texture file" +# define FT_ERR_RD_WE "could not find west side texture file" +# define FT_ERR_RD_SP "could not find sprite texture file" +# define FT_ERR_RD_SB "could not find skybox file" +# define FT_ERR_RD_NL_TEX "could not find next level texture file" +# define FT_ERR_RD_NL_MAP "could not find next level map file" +# define FT_ERR_RD_MUSIC "could not find music file" +# define FT_ERR_RD_TRAP "could not find trap texture file" +# define FT_ERR_WR_BMP "could not export to bmp" +# define FT_ERR_TOO_MUCH_HEALS "too much heal packs, limit is 64" +# define FT_ERR_TOO_MUCH_TRAPS "too much traps, limit is 512" /* ** ====== MISSING ERROR MSG ====== @@ -210,22 +215,24 @@ enum # define FT_ERR_MISS_CEIL_C "ceiling color" # define FT_ERR_MISS_PLAYER_SPAWN "player spawn" # define FT_ERR_MISS_TRAP "traps" -# define FT_ERR_MISS_SFX_DEATH "missing sound effect death" -# define FT_ERR_MISS_SFX_N_LVL "missing sound effect new level" -# define FT_ERR_MISS_SFX_SCR_ONE "missing sound effect scream one" -# define FT_ERR_MISS_SFX_SCR_TWO "missing sound effect scream two" -# define FT_ERR_MISS_SFX_TRAP "missing sound effect trap" -# define FT_ERR_MISS_DEATH_SCREEN "missing death screen image" -# define FT_ERR_MISS_HUD_BACK "missing HUD background image" -# define FT_ERR_MISS_W_ONE "missing HUD background image" -# define FT_ERR_MISS_W_ONE_FIRE "missing HUD background image" -# define FT_ERR_MISS_W_TWO "missing HUD background image" -# define FT_ERR_MISS_W_TWO_FIRE "missing HUD background image" +# define FT_ERR_MISS_SFX_DEATH "sound effect death" +# define FT_ERR_MISS_SFX_N_LVL "sound effect new level" +# define FT_ERR_MISS_SFX_SCR_ONE "sound effect scream one" +# define FT_ERR_MISS_SFX_SCR_TWO "sound effect scream two" +# define FT_ERR_MISS_SFX_TRAP "sound effect trap" +# 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_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" /* ** ====== OTHER ====== */ # define FT_PARSE_END_RET 25 +# define FT_HEAL_PACK_AMOUNT 10 # endif diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index a08d7b2..dc2b411 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -113,8 +113,8 @@ typedef struct s_sprite int32_t y; int32_t tex_x; int32_t tex_y; - int32_t s_pos_x; - int32_t s_pos_y; + uint64_t s_pos_x; + uint64_t s_pos_y; double spritex; double spritey; int32_t spriteheight; @@ -204,9 +204,11 @@ typedef struct s_map size_t mapl_len; int32_t sprite_nbr; uint8_t sprite_var; - int32_t sprite_order[4096]; + int32_t sprite_order[8][4096]; int32_t traps_nbr; + int32_t heals_nbr; int32_t traps_order[512]; + int32_t heals_order[64]; size_t line_chk; size_t map_start; uint8_t isspawn; @@ -216,6 +218,7 @@ typedef struct s_map uint8_t isctex; uint8_t isskybox; uint8_t istraps; + uint8_t isheals; uint8_t darklvl; uint8_t scale; int8_t topsp; @@ -250,9 +253,10 @@ typedef struct s_cub struct s_img death_screen; struct s_rgb f_rgb; struct s_rgb c_rgb; - struct s_img tlist[17]; + struct s_img tlist[18]; struct s_sprite **sprites; struct s_sprite traps[512]; + struct s_sprite heals[64]; struct s_sfx sfx; } t_cub; |