aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_bad_boy_actions.c4
-rw-r--r--src/ft_check_missing_sfx.c17
-rw-r--r--src/ft_damage_bad_boy.c4
-rw-r--r--src/ft_del_sfx_cmd.c3
-rw-r--r--src/ft_exit.c2
-rw-r--r--src/ft_init_sfx.c21
-rw-r--r--src/ft_sfx_bb_death.c42
-rw-r--r--src/ft_sfx_bb_fire.c42
-rw-r--r--src/ft_sfx_bb_scream.c48
-rw-r--r--src/ft_sfx_pain.c2
10 files changed, 174 insertions, 11 deletions
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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */