diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-03 22:52:35 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-03 22:52:35 +0200 |
commit | b92f5be51992760fec0fc110c46ea6cb15e962a8 (patch) | |
tree | 8b3282a61a4bfc53a4c975bb38524ad3cf2ea290 /src | |
parent | YES (diff) | |
download | 42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.gz 42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.bz2 42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.xz 42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.tar.zst 42-cub3d-b92f5be51992760fec0fc110c46ea6cb15e962a8.zip |
Not quite done
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_select_bad_boy_action.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/ft_select_bad_boy_action.c b/src/ft_select_bad_boy_action.c index 5a4f5be..3f3ca6f 100644 --- a/src/ft_select_bad_boy_action.c +++ b/src/ft_select_bad_boy_action.c @@ -94,13 +94,15 @@ int8_t if (cl->sprites[13][id].s_pos_y > cl->plist.pos_y) { while (a2 < cl->sprites[13][id].s_pos_y - cl->plist.pos_y) - a2 += 0.005; + a2 += 0.0005; } - else + else if (cl->sprites[13][id].s_pos_y < cl->plist.pos_y) { while (a2 < cl->plist.pos_y - cl->sprites[13][id].s_pos_y) - a2 += 0.005; + a2 += 0.0005; } + else + a2 = d; if (a2 != d) { teta = acos(a2 / d); @@ -113,18 +115,20 @@ int8_t cl->rlist.y_ray_dir = 1; cl->rlist.x_ray_dir = 1 * sin(teta); } + if (cl->plist.pos_y > cl->sprites[13][id].s_pos_y) + cl->rlist.y_ray_dir = -cl->rlist.y_ray_dir; if (cl->plist.pos_x > cl->sprites[13][id].s_pos_x) cl->rlist.x_ray_dir = -cl->rlist.x_ray_dir; hit = 0; cl->rlist.y_ray_pos = cl->plist.pos_y; cl->rlist.x_ray_pos = cl->plist.pos_x; - cl->rlist.sqy = (uint64_t)cl->rlist.y_ray_pos; - cl->rlist.sqx = (uint64_t)cl->rlist.x_ray_pos; + cl->rlist.sqy = lround(cl->rlist.y_ray_pos); + cl->rlist.sqx = lround(cl->rlist.x_ray_pos); ft_detection_init_x(cl); ft_detection_init_y(cl); while (hit == 0 && - (cl->rlist.sqy != (uint64_t)cl->sprites[13][id].s_pos_y || - cl->rlist.sqx != (uint64_t)cl->sprites[13][id].s_pos_x)) + (cl->rlist.sqy != (unsigned)lround(cl->sprites[13][id].s_pos_y) || + cl->rlist.sqx != (unsigned)lround(cl->sprites[13][id].s_pos_x))) { if (cl->rlist.x_side_dist < cl->rlist.y_side_dist) { @@ -161,8 +165,7 @@ void 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 && - d > FT_ENMY_SIGHT_RANGE) + else if (cl->bad_boy[i].sleep == 0 && cl->bad_boy[i].life > 0) { r = ft_set_r_i(); ft_bb_act(r, i, cl); @@ -173,16 +176,16 @@ void ft_select_bad_boy_action(t_cub *cl) { int8_t i; - double d; + /* double d; */ i = 0; while (i < cl->mlist.sprite_nbr[13]) { - if ((d = ft_get_dist(cl->sprites[13][i], cl)) - <= 4 * FT_ENMY_SIGHT_RANGE && cl->bad_boy[i].sleep == 0) - { - ft_select_action(i, d, cl); - } + /* if ((d = ft_get_dist(cl->sprites[13][i], cl)) */ + /* <= 4 * FT_ENMY_SIGHT_RANGE && cl->bad_boy[i].sleep == 0) */ + /* { */ + ft_select_action(i, ft_get_dist(cl->sprites[13][i], cl), cl); + /* } */ i++; } } |