From 2ad0774ca20e56a4c64cd1fa6531739c701a61ed Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 13 Mar 2020 04:54:43 +0100 Subject: I fucking love it --- src/ft_exit.c | 2 ++ src/ft_init_sfx.c | 4 +++- src/ft_sfx_trap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/ft_suffer_animation.c | 2 ++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/ft_sfx_trap.c (limited to 'src') diff --git a/src/ft_exit.c b/src/ft_exit.c index 28a1489..b0d7ada 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -38,6 +38,8 @@ static void ft_memdel((void**)&clist->mlist.mapl); ft_free_words(clist->mlist.map); ft_free_words(clist->mlist.mcmd_words); + ft_free_words(clist->sfx.death); + ft_free_words(clist->sfx.trap); ft_free_sprites(clist->mlist.sprite_path); if (!clist->wlist.inited) ft_memdel((void**)&clist->wlist.winptr); diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c index 1452b5c..2aed165 100644 --- a/src/ft_init_sfx.c +++ b/src/ft_init_sfx.c @@ -41,7 +41,9 @@ int8_t ft_init_sfx(t_sfx *sfx) { if (ft_split_sfx(&sfx->death, FT_SFX_DEATH_PATH) < 0 || - ft_split_sfx(&sfx->trap, FT_SFX_TRAP_PATH) < 0) + ft_split_sfx(&sfx->trap, FT_SFX_TRAP_PATH) < 0 || + ft_split_sfx(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 || + ft_split_sfx(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0) return (-1); return (0); } diff --git a/src/ft_sfx_trap.c b/src/ft_sfx_trap.c new file mode 100644 index 0000000..bf9e0b2 --- /dev/null +++ b/src/ft_sfx_trap.c @@ -0,0 +1,44 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_music.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/24 17:17:54 by rbousset #+# #+# */ +/* Updated: 2020/02/24 17:17:56 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +static void + ft_sfx_pain(t_cub *cl) +{ + static uint8_t ref_scr = 0; + + ref_scr += 1; + if (ref_scr > 201) + ref_scr = 0; + if (ref_scr % 2) + { + cl->pain_pid = fork(); + if (cl->pain_pid == 0) + { + if (ref_scr % 3) + execve(*(cl->sfx.pain_one + 0), cl->sfx.pain_one, cl->envp); + else + execve(*(cl->sfx.pain_two + 0), cl->sfx.pain_two, cl->envp); + } + } +} + +void + ft_sfx_trap(t_cub *cl) +{ + cl->trap_pid = fork(); + if (cl->trap_pid == 0) + execve(*(cl->sfx.trap + 0), cl->sfx.trap, cl->envp); + ft_sfx_pain(cl); +} diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 28a0d12..67a557f 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -45,7 +45,9 @@ void cl->plist.isdead = 1; ft_warp_level(cl->mlist.filename, cl); } + ft_sfx_trap(cl); /* TODO death screen here */ + } void -- cgit v1.2.3