diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-31 16:19:22 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-31 16:19:22 +0200 |
commit | 2ea18fb7e893691389108ae7731e26576715ca13 (patch) | |
tree | c6a4ccfb785ff7289279d6b08997939c36b4c9ca | |
parent | Good (diff) | |
download | 42-cub3d-2ea18fb7e893691389108ae7731e26576715ca13.tar.gz 42-cub3d-2ea18fb7e893691389108ae7731e26576715ca13.tar.bz2 42-cub3d-2ea18fb7e893691389108ae7731e26576715ca13.tar.xz 42-cub3d-2ea18fb7e893691389108ae7731e26576715ca13.tar.zst 42-cub3d-2ea18fb7e893691389108ae7731e26576715ca13.zip |
Alright sounds
Diffstat (limited to '')
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | inc/cub3d.h | 6 | ||||
-rw-r--r-- | inc/cub3d_defines.h | 5 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 2 | ||||
-rw-r--r-- | media/sound/sfx/skel_death.wav | bin | 0 -> 257772 bytes | |||
-rw-r--r-- | media/sound/sfx/skel_gun.wav | bin | 0 -> 49570 bytes | |||
-rw-r--r-- | media/sound/sfx/skel_scream_one.wav | bin | 0 -> 132128 bytes | |||
-rw-r--r-- | media/sound/sfx/skel_scream_two.wav | bin | 0 -> 136212 bytes | |||
-rw-r--r-- | src/ft_bad_boy_actions.c | 4 | ||||
-rw-r--r-- | src/ft_check_missing_sfx.c | 17 | ||||
-rw-r--r-- | src/ft_damage_bad_boy.c | 4 | ||||
-rw-r--r-- | src/ft_del_sfx_cmd.c | 3 | ||||
-rw-r--r-- | src/ft_exit.c | 2 | ||||
-rw-r--r-- | src/ft_init_sfx.c | 21 | ||||
-rw-r--r-- | src/ft_sfx_bb_death.c | 42 | ||||
-rw-r--r-- | src/ft_sfx_bb_fire.c | 42 | ||||
-rw-r--r-- | src/ft_sfx_bb_scream.c | 48 | ||||
-rw-r--r-- | src/ft_sfx_pain.c | 2 |
18 files changed, 189 insertions, 12 deletions
@@ -131,6 +131,9 @@ SRCS_NAME += ft_bad_boy_actions.c SRCS_NAME += ft_select_bad_boy_action.c SRCS_NAME += ft_collision.c SRCS_NAME += ft_damage_bad_boy.c +SRCS_NAME += ft_sfx_bb_death.c +SRCS_NAME += ft_sfx_bb_scream.c +SRCS_NAME += ft_sfx_bb_fire.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# diff --git a/inc/cub3d.h b/inc/cub3d.h index f392354..d86cf74 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -216,6 +216,9 @@ 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_bb_death(t_sfx *sfx); +void ft_sfx_bb_scream(t_sfx *sfx); +void ft_sfx_bb_fire(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); @@ -229,6 +232,9 @@ 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); +void *ft_sfx_bb_death_thread(void *vargp); +void *ft_sfx_bb_scream_thread(void *vargp); +void *ft_sfx_bb_fire_thread(void *vargp); /* ** ====== TIMINGS ====== diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index 2c586d8..65d60fa 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -109,6 +109,10 @@ enum # 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_SFX_ENMY_DEATH_PATH "./media/sound/sfx/skel_death.wav" +# define FT_SFX_ENMY_SCR_ONE_PATH "./media/sound/sfx/skel_scream_one.wav" +# define FT_SFX_ENMY_SCR_TWO_PATH "./media/sound/sfx/skel_scream_two.wav" +# define FT_SFX_ENMY_FIRE_PATH "./media/sound/sfx/skel_gun.wav" # define FT_DEATH_SCREEN_PATH "./media/img/screens/death_screen.xpm" # define FT_HUD_BACK_PATH "./media/img/hud/hud_back_small.xpm" # define FT_WEAPON_ONE_SPR_PATH "./media/img/weapons/sword_s.xpm" @@ -274,6 +278,7 @@ enum # 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_SFX_ENMY "one or several enemy 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" diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 9ebc305..7aea071 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -277,7 +277,7 @@ typedef struct s_cub struct s_img tweap[6]; struct s_img tnum[12]; struct s_sprite **sprites; - struct s_sfx sfx[13]; + struct s_sfx sfx[16]; struct s_bad_boy *bad_boy; } t_cub; diff --git a/media/sound/sfx/skel_death.wav b/media/sound/sfx/skel_death.wav Binary files differnew file mode 100644 index 0000000..011fe4f --- /dev/null +++ b/media/sound/sfx/skel_death.wav diff --git a/media/sound/sfx/skel_gun.wav b/media/sound/sfx/skel_gun.wav Binary files differnew file mode 100644 index 0000000..7ca45fe --- /dev/null +++ b/media/sound/sfx/skel_gun.wav diff --git a/media/sound/sfx/skel_scream_one.wav b/media/sound/sfx/skel_scream_one.wav Binary files differnew file mode 100644 index 0000000..19e541c --- /dev/null +++ b/media/sound/sfx/skel_scream_one.wav diff --git a/media/sound/sfx/skel_scream_two.wav b/media/sound/sfx/skel_scream_two.wav Binary files differnew file mode 100644 index 0000000..0a58118 --- /dev/null +++ b/media/sound/sfx/skel_scream_two.wav diff --git a/src/ft_bad_boy_actions.c b/src/ft_bad_boy_actions.c index d56037e..49f5a26 100644 --- a/src/ft_bad_boy_actions.c +++ b/src/ft_bad_boy_actions.c @@ -71,8 +71,8 @@ void { if (cl->bad_boy[i].does == 2 && cl->bad_boy[i].sleep == 0) { - cl->sfx[11].sfx_play(cl->sfx); - /* TODO: true bad boy sfx here */ + cl->sfx[15].sfx_play(cl->sfx); + /* TODO: random shot */ if (FT_OS == 1) ft_macos_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); else diff --git a/src/ft_check_missing_sfx.c b/src/ft_check_missing_sfx.c index 34d08e2..0d4411a 100644 --- a/src/ft_check_missing_sfx.c +++ b/src/ft_check_missing_sfx.c @@ -14,6 +14,21 @@ #include <cub3d.h> static int + ft_check_missing_enemy_sfx(t_cub *clist) +{ + if (ft_check_not_found(FT_SFX_ENMY_DEATH_PATH) < 0 || + ft_check_ext(FT_SFX_ENMY_DEATH_PATH, ".wav") < 0 || + ft_check_not_found(FT_SFX_ENMY_SCR_ONE_PATH) < 0 || + ft_check_ext(FT_SFX_ENMY_SCR_ONE_PATH, ".wav") < 0 || + ft_check_not_found(FT_SFX_ENMY_SCR_TWO_PATH) < 0 || + ft_check_ext(FT_SFX_ENMY_SCR_TWO_PATH, ".wav") < 0 || + ft_check_not_found(FT_SFX_ENMY_FIRE_PATH) < 0 || + ft_check_ext(FT_SFX_ENMY_FIRE_PATH, ".wav") < 0) + return (ft_missing_error(FT_ERR_MISS_SFX_ENMY, clist)); + return (0); +} + +static int ft_check_missing_weapon_sfx(t_cub *clist) { if (ft_check_not_found(FT_SFX_W_ONE_LOAD_PATH) < 0 || @@ -37,7 +52,7 @@ static int if (ft_check_not_found(FT_SFX_OOA_PATH) < 0 || ft_check_ext(FT_SFX_OOA_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_OOA, clist)); - return (0); + return (ft_check_missing_enemy_sfx(clist)); } int diff --git a/src/ft_damage_bad_boy.c b/src/ft_damage_bad_boy.c index c9cb66c..27a41ad 100644 --- a/src/ft_damage_bad_boy.c +++ b/src/ft_damage_bad_boy.c @@ -42,5 +42,7 @@ void cl->bad_boy[id].life -= FT_W_TWO_DANAGE_AMOUNT; else if (cl->plist.handles_weapon == 4) cl->bad_boy[id].life -= FT_W_THREE_DANAGE_AMOUNT; - /* TODO: sfx enemy scream and death */ + if (cl->bad_boy[id].does != 3) + cl->sfx[14].sfx_play(cl->sfx); + /* TODO: sfx enemy death */ } diff --git a/src/ft_del_sfx_cmd.c b/src/ft_del_sfx_cmd.c index 4fd38ee..9d33eb9 100644 --- a/src/ft_del_sfx_cmd.c +++ b/src/ft_del_sfx_cmd.c @@ -20,11 +20,12 @@ void uint8_t i; i = 0; - while (i < 13) + while (i < 16) { ft_memdel((void*)&clist->sfx[i].cmd); i++; } ft_memdel((void*)&clist->sfx[1].cmd_alt); ft_memdel((void*)&clist->sfx[3].cmd_alt); + ft_memdel((void*)&clist->sfx[14].cmd_alt); } diff --git a/src/ft_exit.c b/src/ft_exit.c index 79b3068..85c812f 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -49,7 +49,7 @@ static void pthread_join(clist->mtid, NULL); } i = -1; - while (++i < 13) + while (++i < 16) { pthread_mutex_unlock(&clist->sfx[i].mutex); pthread_cancel(clist->sfx[i].tid); diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c index 9b58656..697f3f9 100644 --- a/src/ft_init_sfx.c +++ b/src/ft_init_sfx.c @@ -35,6 +35,9 @@ ** 10: weapon three load ** 11: weapon three fire ** 12: out of ammunitions +** 13: enemy death +** 14: enemy scream | double +** 15: enemy fire */ static int8_t @@ -71,8 +74,10 @@ static void ft_sfx_weapon_three_load_thread, &cl->sfx); pthread_create(&cl->sfx[11].tid, NULL, ft_sfx_weapon_three_fire_thread, &cl->sfx); - pthread_create(&cl->sfx[12].tid, NULL, - ft_sfx_ooa_thread, &cl->sfx); + pthread_create(&cl->sfx[12].tid, NULL, ft_sfx_ooa_thread, &cl->sfx); + pthread_create(&cl->sfx[13].tid, NULL, ft_sfx_bb_death_thread, &cl->sfx); + pthread_create(&cl->sfx[14].tid, NULL, ft_sfx_bb_scream_thread, &cl->sfx); + pthread_create(&cl->sfx[15].tid, NULL, ft_sfx_bb_fire_thread, &cl->sfx); } static void @@ -91,12 +96,16 @@ static void cl->sfx[10].sfx_play = ft_sfx_weapon_three_load; cl->sfx[11].sfx_play = ft_sfx_weapon_three_fire; cl->sfx[12].sfx_play = ft_sfx_ooa; + cl->sfx[13].sfx_play = ft_sfx_bb_death; + cl->sfx[14].sfx_play = ft_sfx_bb_scream; + cl->sfx[15].sfx_play = ft_sfx_bb_fire; } int8_t ft_init_sfx(t_cub *cl) { uint8_t i; + if (ft_init_sfx_cmd(&cl->sfx[0].cmd, FT_SFX_DEATH_PATH) < 0 || ft_init_sfx_cmd(&cl->sfx[1].cmd, FT_SFX_FS_ONE_PATH) < 0 || ft_init_sfx_cmd(&cl->sfx[1].cmd_alt, FT_SFX_FS_TWO_PATH) < 0 || @@ -111,10 +120,14 @@ int8_t ft_init_sfx_cmd(&cl->sfx[9].cmd, FT_SFX_W_TWO_FIRE_PATH) < 0 || ft_init_sfx_cmd(&cl->sfx[10].cmd, FT_SFX_W_THREE_LOAD_PATH) < 0 || ft_init_sfx_cmd(&cl->sfx[11].cmd, FT_SFX_W_THREE_FIRE_PATH) < 0 || - ft_init_sfx_cmd(&cl->sfx[12].cmd, FT_SFX_OOA_PATH) < 0) + ft_init_sfx_cmd(&cl->sfx[12].cmd, FT_SFX_OOA_PATH) < 0 || + ft_init_sfx_cmd(&cl->sfx[13].cmd, FT_SFX_ENMY_DEATH_PATH) < 0 || + ft_init_sfx_cmd(&cl->sfx[14].cmd, FT_SFX_ENMY_SCR_ONE_PATH) < 0 || + ft_init_sfx_cmd(&cl->sfx[14].cmd_alt, FT_SFX_ENMY_SCR_TWO_PATH) < 0 || + ft_init_sfx_cmd(&cl->sfx[15].cmd, FT_SFX_ENMY_FIRE_PATH) < 0) return (-1); i = -1; - while (++i < 13) + while (++i < 16) pthread_mutex_init(&cl->sfx[i].mutex, NULL); ft_init_sfx_pthreads(cl); ft_init_sfx_funptr(cl); diff --git a/src/ft_sfx_bb_death.c b/src/ft_sfx_bb_death.c new file mode 100644 index 0000000..ce86c82 --- /dev/null +++ b/src/ft_sfx_bb_death.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sfx_bb_death.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 17:17:54 by rbousset #+# #+# */ +/* Updated: 2020/02/24 17:17:56 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <cub3d.h> +#include <stddef.h> +#include <stdlib.h> +#include <pthread.h> + +void + *ft_sfx_bb_death_thread(void *vargp) +{ + t_sfx *sfx; + + if (FT_OS == 1) + pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + else + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + sfx = (t_sfx *)vargp; + pthread_mutex_lock(&sfx[13].mutex); + while (1) + { + pthread_mutex_lock(&sfx[13].mutex); + if (system(sfx[13].cmd)) + pthread_exit(NULL); + } + return (NULL); +} + +void + ft_sfx_bb_death(t_sfx *sfx) +{ + pthread_mutex_unlock(&sfx[13].mutex); +} diff --git a/src/ft_sfx_bb_fire.c b/src/ft_sfx_bb_fire.c new file mode 100644 index 0000000..8ebeb6d --- /dev/null +++ b/src/ft_sfx_bb_fire.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sfx_bb_fire.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 17:17:54 by rbousset #+# #+# */ +/* Updated: 2020/02/24 17:17:56 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <cub3d.h> +#include <stddef.h> +#include <stdlib.h> +#include <pthread.h> + +void + *ft_sfx_bb_fire_thread(void *vargp) +{ + t_sfx *sfx; + + if (FT_OS == 1) + pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + else + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + sfx = (t_sfx *)vargp; + pthread_mutex_lock(&sfx[15].mutex); + while (1) + { + pthread_mutex_lock(&sfx[15].mutex); + if (system(sfx[15].cmd)) + pthread_exit(NULL); + } + return (NULL); +} + +void + ft_sfx_bb_fire(t_sfx *sfx) +{ + pthread_mutex_unlock(&sfx[15].mutex); +} diff --git a/src/ft_sfx_bb_scream.c b/src/ft_sfx_bb_scream.c new file mode 100644 index 0000000..da93bdc --- /dev/null +++ b/src/ft_sfx_bb_scream.c @@ -0,0 +1,48 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sfx_bb_scream.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 17:17:54 by rbousset #+# #+# */ +/* Updated: 2020/02/24 17:17:56 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <cub3d.h> +#include <stdlib.h> +#include <pthread.h> + +void + *ft_sfx_bb_scream_thread(void *vargp) +{ + t_sfx *sfx; + static uint8_t ref = 0; + + if (FT_OS == 1) + pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + else + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + sfx = (t_sfx *)vargp; + pthread_mutex_lock(&sfx[14].mutex); + while (1) + { + pthread_mutex_lock(&sfx[14].mutex); + ref = (ref > 201) ? (0) : (ref + 1); + if (ref % 3) + { + if (system(sfx[14].cmd)) + pthread_exit(NULL); + } + else if (system(sfx[14].cmd_alt)) + pthread_exit(NULL); + } + return (NULL); +} + +void + ft_sfx_bb_scream(t_sfx *sfx) +{ + pthread_mutex_unlock(&sfx[14].mutex); +} diff --git a/src/ft_sfx_pain.c b/src/ft_sfx_pain.c index 890f38c..d7ad5ef 100644 --- a/src/ft_sfx_pain.c +++ b/src/ft_sfx_pain.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_sfx_trap.c :+: :+: :+: */ +/* ft_sfx_pain.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ |