diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-22 16:58:26 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-22 16:58:26 +0100 |
commit | b34688558a7b9d2b1f95c00a33197cdc017e8dc5 (patch) | |
tree | 51c0339d1252a1384113767f1efa5a285f05b325 /src/ft_suffer_animation.c | |
parent | Raycasting normed (diff) | |
download | 42-cub3d-b34688558a7b9d2b1f95c00a33197cdc017e8dc5.tar.gz 42-cub3d-b34688558a7b9d2b1f95c00a33197cdc017e8dc5.tar.bz2 42-cub3d-b34688558a7b9d2b1f95c00a33197cdc017e8dc5.tar.xz 42-cub3d-b34688558a7b9d2b1f95c00a33197cdc017e8dc5.tar.zst 42-cub3d-b34688558a7b9d2b1f95c00a33197cdc017e8dc5.zip |
Norm so far
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; } |