aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_select_bad_boy_action.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_select_bad_boy_action.c')
-rw-r--r--src/ft_select_bad_boy_action.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ft_select_bad_boy_action.c b/src/ft_select_bad_boy_action.c
index a151432..bb4894d 100644
--- a/src/ft_select_bad_boy_action.c
+++ b/src/ft_select_bad_boy_action.c
@@ -122,27 +122,27 @@ int8_t
}
static void
- ft_select_action(int8_t i, t_cub *cl)
+ ft_select_action(int8_t i, double d, t_cub *cl)
{
int8_t can_shoot;
int8_t r;
can_shoot = ft_can_it_shoot(i, cl);
if (cl->bad_boy[i].sleep == 0 && cl->bad_boy[i].life > 0 &&
- (ft_get_dist(cl->sprites[13][i], cl) <= 1 || can_shoot == 1))
+ (d <= 1 || can_shoot == 1))
{
r = ft_set_r_ii();
ft_bb_act(r, i, cl);
}
else if (cl->bad_boy[i].sleep == 0 && cl->bad_boy[i].life > 0 &&
- (ft_get_dist(cl->sprites[13][i], cl) <= FT_ENMY_SIGHT_RANGE &&
+ (d <= FT_ENMY_SIGHT_RANGE &&
can_shoot == 1))
{
r = ft_set_r_ii();
ft_bb_act(r, i, cl);
}
else if (cl->bad_boy[i].sleep == 0 && cl->bad_boy[i].life > 0 &&
- ft_get_dist(cl->sprites[13][i], cl) > FT_ENMY_SIGHT_RANGE)
+ d > FT_ENMY_SIGHT_RANGE)
{
r = ft_set_r_i();
ft_bb_act(r, i, cl);
@@ -154,13 +154,15 @@ void
ft_select_bad_boy_action(t_cub *cl)
{
int8_t i;
+ double d;
i = 0;
while (i < cl->mlist.sprite_nbr[13])
{
- if (ft_get_dist(cl->sprites[13][i], cl) < 4 * FT_ENMY_SIGHT_RANGE)
+ if ((d = ft_get_dist(cl->sprites[13][i], cl))
+ <= 4 * FT_ENMY_SIGHT_RANGE)
{
- ft_select_action(i, cl);
+ ft_select_action(i, d, cl);
}
i++;
}