From 643d99cd3faf1b52d740552e00363e8e7777b6ae Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 29 Mar 2020 18:30:21 +0200 Subject: Better sword --- src/ft_shoot.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ft_shoot.c b/src/ft_shoot.c index bc9a126..09061b8 100644 --- a/src/ft_shoot.c +++ b/src/ft_shoot.c @@ -10,8 +10,9 @@ /* */ /* ************************************************************************** */ -#include #include +#include +#include static void ft_hide_sprite(t_cub *cl) @@ -43,6 +44,16 @@ static void cl->sprites[i][j].s_pos_y = 0; } +static int8_t + ft_weap_range(t_cub *cl) +{ + if (cl->plist.handles_weapon == 0 && + sqrtf(powf(cl->plist.pos_x - cl->rlist.sqy, 2) + + powf(cl->plist.pos_y - cl->rlist.sqx, 2)) < 1.5) + return (1); + return (0); +} + static void ft_hitscan(t_cub *cl, uint16_t hit) { @@ -61,7 +72,7 @@ static void cl->rlist.side = 1; } if (ft_ischarset(FT_CHRST_SPRITES, - cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy])) + cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy]) && ft_weap_range(cl)) { hit = 1; ft_hide_sprite(cl); -- cgit v1.2.3