aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_shoot.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-29 18:30:21 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-29 18:30:21 +0200
commit643d99cd3faf1b52d740552e00363e8e7777b6ae (patch)
treebd5adc71aa7842ac04f1b9b068fcd37e9c5bd867 /src/ft_shoot.c
parentNorm (diff)
download42-cub3d-643d99cd3faf1b52d740552e00363e8e7777b6ae.tar.gz
42-cub3d-643d99cd3faf1b52d740552e00363e8e7777b6ae.tar.bz2
42-cub3d-643d99cd3faf1b52d740552e00363e8e7777b6ae.tar.xz
42-cub3d-643d99cd3faf1b52d740552e00363e8e7777b6ae.tar.zst
42-cub3d-643d99cd3faf1b52d740552e00363e8e7777b6ae.zip
Better sword
Diffstat (limited to '')
-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);