diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-03 17:11:26 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-03 17:11:26 +0200 |
commit | fa65d126ba3738bf7dcf8a0dae56a35adab6fd51 (patch) | |
tree | 9a51b432041365f7ba13a9cd63ebe09281620074 /src | |
parent | Optimization, still math missing (diff) | |
download | 42-cub3d-fa65d126ba3738bf7dcf8a0dae56a35adab6fd51.tar.gz 42-cub3d-fa65d126ba3738bf7dcf8a0dae56a35adab6fd51.tar.bz2 42-cub3d-fa65d126ba3738bf7dcf8a0dae56a35adab6fd51.tar.xz 42-cub3d-fa65d126ba3738bf7dcf8a0dae56a35adab6fd51.tar.zst 42-cub3d-fa65d126ba3738bf7dcf8a0dae56a35adab6fd51.zip |
Even better but where is the math
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_select_bad_boy_action.c | 14 |
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++; } |