diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-01 19:37:00 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-01 19:37:00 +0200 |
commit | c2fabd5bee8cc8a386d2012e6b08471955fbcaa8 (patch) | |
tree | dd59fd3f0c76d4ac79efc403908092e31cf91a1f | |
parent | ok (diff) | |
download | 42-cub3d-c2fabd5bee8cc8a386d2012e6b08471955fbcaa8.tar.gz 42-cub3d-c2fabd5bee8cc8a386d2012e6b08471955fbcaa8.tar.bz2 42-cub3d-c2fabd5bee8cc8a386d2012e6b08471955fbcaa8.tar.xz 42-cub3d-c2fabd5bee8cc8a386d2012e6b08471955fbcaa8.tar.zst 42-cub3d-c2fabd5bee8cc8a386d2012e6b08471955fbcaa8.zip |
Later
Diffstat (limited to '')
-rw-r--r-- | inc/cub3d.h | 2 | ||||
-rw-r--r-- | map/map_seven.cub | 4 | ||||
-rw-r--r-- | src/ft_extra_keys.c | 2 | ||||
-rw-r--r-- | src/ft_select_bad_boy_action.c | 59 | ||||
-rw-r--r-- | src/ft_shoot.c | 13 |
5 files changed, 60 insertions, 20 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h index d86cf74..87005e9 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -284,7 +284,7 @@ void ft_find_item(t_player *pl, t_map *ml, t_cub *cl); int8_t ft_switch_weap_one(t_cub *cl); int8_t ft_switch_weap_two(t_cub *cl); int8_t ft_switch_weap_three(t_cub *cl); -void ft_shoot(t_cub *cl, uint16_t center); +void ft_shoot(t_cub *cl); int ft_handle_keys(uint8_t i, float old_y, float old_x, t_cub *cl); # endif diff --git a/map/map_seven.cub b/map/map_seven.cub index 93afdff..65dce79 100644 --- a/map/map_seven.cub +++ b/map/map_seven.cub @@ -1,4 +1,4 @@ -R 800 600 +R 1024 768 NO ./media/img/tex/plate_small.xpm SO ./media/img/tex/plate_small.xpm @@ -15,7 +15,7 @@ C 150,150,150 1000000000000000001 1000000000000000001 100000000e000000001 -1000000000000000001 +1000011111111100001 1000000000000000001 1000000000000000001 1000000000000000001 diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c index 1a71402..03c6f75 100644 --- a/src/ft_extra_keys.c +++ b/src/ft_extra_keys.c @@ -83,7 +83,7 @@ int clist->plist.ammo[w_id] -= w_id; clist->sfx[clist->plist.handles_weapon + 7].sfx_play(clist->sfx); clist->plist.fire = 1; - ft_shoot(clist, clist->wlist.x_size / 2); + ft_shoot(clist); return (0); } else if (clist->plist.fire == 0 && clist->plist.ammo[w_id] <= 0) diff --git a/src/ft_select_bad_boy_action.c b/src/ft_select_bad_boy_action.c index 73b3f9a..71122eb 100644 --- a/src/ft_select_bad_boy_action.c +++ b/src/ft_select_bad_boy_action.c @@ -16,8 +16,8 @@ #include <math.h> /* -** bad_boy[].act[] - index summary -** ------------------------------- +** bad_boy.act[] - index summary +** ----------------------------- ** 0: wait ** 1: walk ** 2: fire @@ -79,27 +79,70 @@ 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; */ + +/* (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 ft_select_bad_boy_action(t_cub *cl) { int8_t i; int8_t r; + int8_t can_shoot; i = -1; + can_shoot = 0; while (++i < cl->mlist.sprite_nbr[13]) { + /* 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 - || cl->rlist.wall_dist_tab[cl->wlist.x_size / 2] < - ft_get_dist(cl->sprites[13][i], cl))) + (ft_get_dist(cl->sprites[13][i], cl) > FT_ENMY_SIGHT_RANGE || + can_shoot == 0)) { r = ft_set_r_i(); 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 - && cl->rlist.wall_dist_tab[cl->wlist.x_size / 2] > - ft_get_dist(cl->sprites[13][i], cl))) + (ft_get_dist(cl->sprites[13][i], cl) <= FT_ENMY_SIGHT_RANGE && + can_shoot == 1)) { r = ft_set_r_ii(); ft_bb_act(r, i, cl); diff --git a/src/ft_shoot.c b/src/ft_shoot.c index 01a96fd..1797b2d 100644 --- a/src/ft_shoot.c +++ b/src/ft_shoot.c @@ -95,22 +95,19 @@ static void } void - ft_shoot(t_cub *cl, uint16_t i) + ft_shoot(t_cub *cl) { t_win *wl; t_player *pl; wl = &cl->wlist; pl = &cl->plist; - pl->cam_x = 2 * i / (float)(wl->x_size) - 1; cl->rlist.x_ray_pos = pl->pos_y; cl->rlist.y_ray_pos = pl->pos_x; - cl->rlist.x_ray_dir = pl->dir_x + pl->plane_x * - pl->cam_x; - cl->rlist.y_ray_dir = pl->dir_y + pl->plane_y * - pl->cam_x; - cl->rlist.sqx = (int16_t)cl->rlist.x_ray_pos; - cl->rlist.sqy = (int16_t)cl->rlist.y_ray_pos; + cl->rlist.x_ray_dir = pl->dir_x; + cl->rlist.y_ray_dir = pl->dir_y; + cl->rlist.sqx = (uint64_t)cl->rlist.x_ray_pos; + cl->rlist.sqy = (uint64_t)cl->rlist.y_ray_pos; ft_detection_init_x(cl); ft_detection_init_y(cl); ft_hitscan(cl, 0); |