aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ft_shoot.c15
1 files 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 <cub3d.h>
#include <libft.h>
+#include <cub3d.h>
+#include <math.h>
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);