diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_suffer_animation.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 6a325bc..51de24a 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -15,6 +15,23 @@ #include <mlx.h> #include <stdint.h> +static void + ft_get_damaged(t_cub *cl) +{ + cl->plist.life -= FT_TRAP_DAMAGE_AMOUNT; + if (cl->plist.life <= 0) + { + cl->isdead = 1; + cl->sfx[0].sfx_play(cl->sfx); + ft_death_screen(cl); + } + else + { + cl->sfx[4].sfx_play(cl->sfx); + cl->sfx[3].sfx_play(cl->sfx); + } +} + void ft_linux_suffer_animation(t_cub *cl) { @@ -36,18 +53,7 @@ void mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, cl->img.img, 0, 0); mlx_destroy_image(cl->wlist.wlx, cl->img.img); - cl->plist.life -= FT_TRAP_DAMAGE_AMOUNT; - if (cl->plist.life <= 0) - { - cl->isdead = 1; - cl->sfx[0].sfx_play(cl->sfx); - ft_death_screen(cl); - } - else - { - cl->sfx[4].sfx_play(cl->sfx); - cl->sfx[3].sfx_play(cl->sfx); - } + ft_get_damaged(cl); } void @@ -72,17 +78,6 @@ void (x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(rgb); } } - cl->plist.life -= FT_TRAP_DAMAGE_AMOUNT; - if (cl->plist.life <= 0) - { - cl->isdead = 1; - cl->sfx[0].sfx_play(cl->sfx); - ft_death_screen(cl); - } - else - { - cl->sfx[4].sfx_play(cl->sfx); - cl->sfx[3].sfx_play(cl->sfx); - } + ft_get_damaged(cl); cl->doicast = 0; } |