diff options
Diffstat (limited to 'src/ft_suffer_animation.c')
| -rw-r--r-- | src/ft_suffer_animation.c | 45 | 
1 files changed, 20 insertions, 25 deletions
| diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 6a325bc..1b48e47 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 @@ -69,20 +75,9 @@ void  			rgb.g += 20;  			rgb.b += 20;  			*(int*)(cl->img.ptr + -				(x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(rgb); +				(x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(0, rgb, 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); -	} +	ft_get_damaged(cl);  	cl->doicast = 0;  } | 
