diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_bad_boy_actions.c | 22 | ||||
-rw-r--r-- | src/ft_damage_bad_boy.c | 9 | ||||
-rw-r--r-- | src/ft_init_bad_boys.c | 1 | ||||
-rw-r--r-- | src/ft_init_sfx.c | 16 |
4 files changed, 37 insertions, 11 deletions
diff --git a/src/ft_bad_boy_actions.c b/src/ft_bad_boy_actions.c index 49f5a26..92fe3fa 100644 --- a/src/ft_bad_boy_actions.c +++ b/src/ft_bad_boy_actions.c @@ -61,22 +61,34 @@ void bl->does = 1; } +/* +** skelton misses one random +** shot out of four +*/ + void ft_check_bad_boy_shoot(t_cub *cl) { int8_t i; + int8_t r; i = 0; while (i < cl->mlist.sprite_nbr[13]) { + if (FT_OS == 1) + r = rand() % 4; + else + r = random() % 4; if (cl->bad_boy[i].does == 2 && cl->bad_boy[i].sleep == 0) { cl->sfx[15].sfx_play(cl->sfx); - /* TODO: random shot */ - if (FT_OS == 1) - ft_macos_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); - else - ft_linux_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); + if (r != 3) + { + if (FT_OS == 1) + ft_macos_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); + else + ft_linux_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); + } } i++; } diff --git a/src/ft_damage_bad_boy.c b/src/ft_damage_bad_boy.c index 27a41ad..2d6bd58 100644 --- a/src/ft_damage_bad_boy.c +++ b/src/ft_damage_bad_boy.c @@ -42,7 +42,12 @@ 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; - if (cl->bad_boy[id].does != 3) + if (cl->bad_boy[id].isdead == 0 && + cl->bad_boy[id].life <= 0) + { + cl->sfx[13].sfx_play(cl->sfx); + cl->bad_boy[id].isdead = 1; + } + else if (cl->bad_boy[id].does != 3) cl->sfx[14].sfx_play(cl->sfx); - /* TODO: sfx enemy death */ } diff --git a/src/ft_init_bad_boys.c b/src/ft_init_bad_boys.c index 100411e..bf4ae67 100644 --- a/src/ft_init_bad_boys.c +++ b/src/ft_init_bad_boys.c @@ -38,6 +38,7 @@ int8_t cl->bad_boy[i].life = FT_ENMY_STRT_LIFE; cl->bad_boy[i].does = 0; cl->bad_boy[i].sleep = 0; + cl->bad_boy[i].isdead = 0; cl->bad_boy[i].act[0] = ft_bb_wait; cl->bad_boy[i].act[1] = ft_bb_walk; cl->bad_boy[i].act[2] = ft_bb_fire; diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c index 697f3f9..1725c91 100644 --- a/src/ft_init_sfx.c +++ b/src/ft_init_sfx.c @@ -101,11 +101,9 @@ static void cl->sfx[15].sfx_play = ft_sfx_bb_fire; } -int8_t - ft_init_sfx(t_cub *cl) +static int8_t + ft_init_sfx_cmds(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 || @@ -126,6 +124,16 @@ int8_t 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); + return (0); +} + +int8_t + ft_init_sfx(t_cub *cl) +{ + uint8_t i; + + if (ft_init_sfx_cmds(cl) < 0) + return (-1); i = -1; while (++i < 16) pthread_mutex_init(&cl->sfx[i].mutex, NULL); |