aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_select_bad_boy_action.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-02 14:24:57 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-02 14:24:57 +0200
commit8a695d62dcb9b8783918263f962b986df20310f2 (patch)
tree37e3c4e286abcec481bbc8169c7297e1ec07b578 /src/ft_select_bad_boy_action.c
parentLater (diff)
download42-cub3d-8a695d62dcb9b8783918263f962b986df20310f2.tar.gz
42-cub3d-8a695d62dcb9b8783918263f962b986df20310f2.tar.bz2
42-cub3d-8a695d62dcb9b8783918263f962b986df20310f2.tar.xz
42-cub3d-8a695d62dcb9b8783918263f962b986df20310f2.tar.zst
42-cub3d-8a695d62dcb9b8783918263f962b986df20310f2.zip
Correct dir_x dir_y sqy sqx
Diffstat (limited to '')
-rw-r--r--src/ft_select_bad_boy_action.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/src/ft_select_bad_boy_action.c b/src/ft_select_bad_boy_action.c
index 71122eb..f0ce7e7 100644
--- a/src/ft_select_bad_boy_action.c
+++ b/src/ft_select_bad_boy_action.c
@@ -79,47 +79,46 @@ static void
cl->bad_boy[i].sleep = 1;
}
-/* int8_t */
-/* ft_can_it_shoot(int8_t id, t_cub *cl) */
-/* { */
-/* uint8_t hit; */
-/* t_win *wl; */
-/* t_player *pl; */
+int8_t
+ ft_can_it_shoot(int8_t id, t_cub *cl)
+{
+ uint8_t hit;
+ t_win *wl;
+ t_player *pl;
-/* (void)id; */
-/* (void)cl; */
-/* wl = &cl->wlist; */
-/* pl = &cl->plist; */
-/* hit = 0; */
-/* cl->rlist.x_ray_pos = cl->plist.pos_y; */
-/* cl->rlist.y_ray_pos = cl->plist.pos_x; */
-/* cl->rlist.x_ray_dir = pl->dir_x; */
-/* cl->rlist.y_ray_dir = pl->dir_y; */
-/* cl->rlist.sqx = (int16_t)cl->rlist.x_ray_pos; */
-/* cl->rlist.sqy = (int16_t)cl->rlist.y_ray_pos; */
-/* ft_detection_init_x(cl); */
-/* ft_detection_init_y(cl); */
-/* while (hit == 0 && (cl->rlist.sqx != (uint64_t)cl->sprites[13][id].s_pos_y && */
-/* cl->rlist.sqy != (uint64_t)cl->sprites[13][id].s_pos_x)) */
-/* { */
-/* 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; */
-/* } */
-/* if (cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] == '1') */
-/* hit = 1; */
-/* } */
-/* ft_printf("%hhu\n", hit); */
-/* return ((hit == 1) ? (0) : (1)); */
-/* } */
+ (void)id;
+ (void)cl;
+ wl = &cl->wlist;
+ pl = &cl->plist;
+ hit = 0;
+ cl->rlist.x_ray_pos = cl->plist.pos_y;
+ cl->rlist.y_ray_pos = cl->plist.pos_x;
+ cl->rlist.x_ray_dir = pl->dir_y;
+ cl->rlist.y_ray_dir = pl->dir_x;
+ cl->rlist.sqy = (uint64_t)cl->rlist.x_ray_pos;
+ cl->rlist.sqx = (uint64_t)cl->rlist.y_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))
+ {
+ if (cl->rlist.x_side_dist < cl->rlist.y_side_dist)
+ {
+ cl->rlist.x_side_dist += cl->rlist.x_delta_dist;
+ cl->rlist.sqy += cl->mlist.x_step;
+ cl->rlist.side = 0;
+ }
+ else
+ {
+ cl->rlist.y_side_dist += cl->rlist.y_delta_dist;
+ cl->rlist.sqx += cl->mlist.y_step;
+ cl->rlist.side = 1;
+ }
+ if (cl->mlist.map[cl->rlist.sqy][cl->rlist.sqx] == '1')
+ hit = 1;
+ }
+ return ((hit == 1) ? (0) : (1));
+}
void
ft_select_bad_boy_action(t_cub *cl)
@@ -132,7 +131,7 @@ void
can_shoot = 0;
while (++i < cl->mlist.sprite_nbr[13])
{
- /* can_shoot = ft_can_it_shoot(i, cl); */
+ 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) > FT_ENMY_SIGHT_RANGE ||
can_shoot == 0))