aboutsummaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-18 21:35:54 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-18 21:35:54 +0100
commitd114d2571a3808eba1f0a5038ad862b790a96074 (patch)
tree8d2d4c19a2a8de61a253dc0a4fc2434a770470a6 /inc
parentMerge branch 'better_sprites' (diff)
download42-cub3d-d114d2571a3808eba1f0a5038ad862b790a96074.tar.gz
42-cub3d-d114d2571a3808eba1f0a5038ad862b790a96074.tar.bz2
42-cub3d-d114d2571a3808eba1f0a5038ad862b790a96074.tar.xz
42-cub3d-d114d2571a3808eba1f0a5038ad862b790a96074.tar.zst
42-cub3d-d114d2571a3808eba1f0a5038ad862b790a96074.zip
In progress
Diffstat (limited to 'inc')
-rw-r--r--inc/cub3d.h3
-rw-r--r--inc/cub3d_defines.h119
-rw-r--r--inc/cub3d_structs.h6
3 files changed, 70 insertions, 58 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 042faa3..4f1bc72 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -84,6 +84,8 @@ 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);
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 1aa380f..237cdad 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
@@ -94,6 +95,7 @@ enum
# define FT_SFX_TRAP_PATH "./media/sound/sfx/trap.wav"
# define FT_DEATH_SCREEN_PATH "./media/img/death_screen.xpm"
# define FT_HUD_BACK_PATH "./media/img/plate_small.xpm"
+# define FT_HEAL_PACK_PATH "./media/img/first_aid.xpm"
/*
** ====== SOUNDS ======
@@ -132,10 +134,10 @@ 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"
@@ -151,43 +153,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 ======
@@ -206,13 +210,14 @@ 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_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"
/*
** ====== OTHER ======
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index 66f139d..e4936eb 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -206,7 +206,9 @@ typedef struct s_map
uint8_t sprite_var;
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;