aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_init_sfx.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 21:59:13 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 21:59:13 +0100
commitb135ba89ccceffa88356cc25f256b0cb2adbd88c (patch)
tree1e87c98d28857abfea2c5199dfdf77516ab28898 /src/ft_init_sfx.c
parentRework in progress (diff)
download42-cub3d-b135ba89ccceffa88356cc25f256b0cb2adbd88c.tar.gz
42-cub3d-b135ba89ccceffa88356cc25f256b0cb2adbd88c.tar.bz2
42-cub3d-b135ba89ccceffa88356cc25f256b0cb2adbd88c.tar.xz
42-cub3d-b135ba89ccceffa88356cc25f256b0cb2adbd88c.tar.zst
42-cub3d-b135ba89ccceffa88356cc25f256b0cb2adbd88c.zip
The og OOP
Diffstat (limited to '')
-rw-r--r--src/ft_init_sfx.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c
index 5efc5a4..6fc8504 100644
--- a/src/ft_init_sfx.c
+++ b/src/ft_init_sfx.c
@@ -19,14 +19,13 @@
#include <unistd.h>
#include <pthread.h>
-
/*
** sfx[] index summary
** -------------------
** 0: death
-** 1: footstep
+** 1: footstep | double
** 2: new level
-** 3: pain
+** 3: pain | double
** 4: trap
** 5: heal
** 6: weapon one load
@@ -51,31 +50,31 @@ static int8_t
static void
ft_init_sfx_pthreads(t_cub *cl)
{
- pthread_create(cl->sfx[0].tid, NULL, ft_sfx_death_thread, sfx);
- pthread_create(cl->sfx[1].tid, NULL, ft_sfx_footstep_thread, sfx);
- pthread_create(cl->sfx[2].tid, NULL, ft_sfx_new_lvl_thread, sfx);
- pthread_create(cl->sfx[3].tid, NULL, ft_sfx_pain_thread, sfx);
- pthread_create(cl->sfx[4].tid, NULL, ft_sfx_trap_thread, sfx);
- pthread_create(cl->sfx[5].tid, NULL, ft_sfx_heal_thread, sfx);
- pthread_create(cl->sfx[6].tid, NULL, ft_sfx_weap_one_load_thread, sfx);
- pthread_create(cl->sfx[7].tid, NULL, ft_sfx_weap_one_fire_thread, sfx);
- pthread_create(cl->sfx[8].tid, NULL, ft_sfx_weap_two_load_thread, sfx);
- pthread_create(cl->sfx[9].tid, NULL, ft_sfx_weap_two_fire_thread, sfx);
+ pthread_create(&cl->sfx[0].tid, NULL, ft_sfx_death_thread, &cl->sfx);
+ pthread_create(&cl->sfx[1].tid, NULL, ft_sfx_footstep_thread, &cl->sfx);
+ pthread_create(&cl->sfx[2].tid, NULL, ft_sfx_new_lvl_thread, &cl->sfx);
+ pthread_create(&cl->sfx[3].tid, NULL, ft_sfx_pain_thread, &cl->sfx);
+ pthread_create(&cl->sfx[4].tid, NULL, ft_sfx_trap_thread, &cl->sfx);
+ pthread_create(&cl->sfx[5].tid, NULL, ft_sfx_heal_thread, &cl->sfx);
+ pthread_create(&cl->sfx[6].tid, NULL, ft_sfx_weapon_one_load_thread, &cl->sfx);
+ pthread_create(&cl->sfx[7].tid, NULL, ft_sfx_weapon_one_fire_thread, &cl->sfx);
+ pthread_create(&cl->sfx[8].tid, NULL, ft_sfx_weapon_two_load_thread, &cl->sfx);
+ pthread_create(&cl->sfx[9].tid, NULL, ft_sfx_weapon_two_fire_thread, &cl->sfx);
}
static void
- ft_init_sfx_funptr(cl)
+ ft_init_sfx_funptr(t_cub *cl)
{
- cl->sfx[0].ft_sfx_play = ft_sfx_death;
- cl->sfx[1].ft_sfx_play = ft_sfx_footstep;
- cl->sfx[2].ft_sfx_play = ft_sfx_new_level;
- cl->sfx[3].ft_sfx_play = ft_sfx_pain;
- cl->sfx[4].ft_sfx_play = ft_sfx_trap;
- cl->sfx[5].ft_sfx_play = ft_sfx_heal;
- cl->sfx[6].ft_sfx_play = ft_sfx_weap_one_load;
- cl->sfx[7].ft_sfx_play = ft_sfx_weap_one_fire;
- cl->sfx[8].ft_sfx_play = ft_sfx_weap_two_load;
- cl->sfx[9].ft_sfx_play = ft_sfx_weap_two_fire;
+ cl->sfx[0].sfx_play = ft_sfx_death;
+ cl->sfx[1].sfx_play = ft_sfx_footstep;
+ cl->sfx[2].sfx_play = ft_sfx_new_level;
+ cl->sfx[3].sfx_play = ft_sfx_pain;
+ cl->sfx[4].sfx_play = ft_sfx_trap;
+ cl->sfx[5].sfx_play = ft_sfx_heal;
+ cl->sfx[6].sfx_play = ft_sfx_weapon_one_load;
+ cl->sfx[7].sfx_play = ft_sfx_weapon_one_fire;
+ cl->sfx[8].sfx_play = ft_sfx_weapon_two_load;
+ cl->sfx[9].sfx_play = ft_sfx_weapon_two_fire;
}
int8_t
@@ -97,7 +96,7 @@ int8_t
return (-1);
i = -1;
while (++i < 10)
- pthread_mutex_init(cl->sfx[i].mutex, NULL);
+ pthread_mutex_init(&cl->sfx[i].mutex, NULL);
ft_init_sfx_pthreads(cl);
ft_init_sfx_funptr(cl);
return (0);