aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_shoot.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-31 14:59:53 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-31 14:59:53 +0200
commitf06a9f89bdbf5123fd00a79d350d599509d689df (patch)
tree396f94876a3d81f14c9cab3b06989c13cc8e6437 /src/ft_shoot.c
parentFixed that gangsta (diff)
download42-cub3d-f06a9f89bdbf5123fd00a79d350d599509d689df.tar.gz
42-cub3d-f06a9f89bdbf5123fd00a79d350d599509d689df.tar.bz2
42-cub3d-f06a9f89bdbf5123fd00a79d350d599509d689df.tar.xz
42-cub3d-f06a9f89bdbf5123fd00a79d350d599509d689df.tar.zst
42-cub3d-f06a9f89bdbf5123fd00a79d350d599509d689df.zip
Big gameplay
Diffstat (limited to 'src/ft_shoot.c')
-rw-r--r--src/ft_shoot.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/ft_shoot.c b/src/ft_shoot.c
index 7f23bfd..5342509 100644
--- a/src/ft_shoot.c
+++ b/src/ft_shoot.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_extra_keys.c :+: :+: :+: */
+/* ft_shoot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -55,30 +55,41 @@ static int8_t
}
static void
+ ft_set_sq(t_cub *cl)
+{
+ if (cl->rlist.x_side_dist < cl->rlist.y_side_dist)
+ {
+ cl->rlist.x_side_dist += cl->rlist.x_delta_dist;
+ cl->rlist.sqx += cl->mlist.x_step;
+ cl->rlist.side = 0;
+ }
+ else
+ {
+ cl->rlist.y_side_dist += cl->rlist.y_delta_dist;
+ cl->rlist.sqy += cl->mlist.y_step;
+ cl->rlist.side = 1;
+ }
+}
+
+static void
ft_hitscan(t_cub *cl, uint16_t hit)
{
while (hit == 0)
{
- if (cl->rlist.x_side_dist < cl->rlist.y_side_dist)
- {
- cl->rlist.x_side_dist += cl->rlist.x_delta_dist;
- cl->rlist.sqx += cl->mlist.x_step;
- cl->rlist.side = 0;
- }
- else
- {
- cl->rlist.y_side_dist += cl->rlist.y_delta_dist;
- cl->rlist.sqy += cl->mlist.y_step;
- cl->rlist.side = 1;
- }
+ ft_set_sq(cl);
if (ft_ischarset(FT_CHRST_SPRITES,
cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy]) && ft_weap_range(cl))
{
hit = 1;
ft_hide_sprite(cl);
}
- else if (ft_ischarset("1",
- cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy]))
+ else if (cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] == 'e' &&
+ ft_weap_range(cl))
+ {
+ hit = 1;
+ ft_damage_bad_boy(cl);
+ }
+ else if (cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] == '1')
hit = 1;
}
}