diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-02 14:24:57 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-02 14:24:57 +0200 |
commit | 8a695d62dcb9b8783918263f962b986df20310f2 (patch) | |
tree | 37e3c4e286abcec481bbc8169c7297e1ec07b578 /src/ft_shoot.c | |
parent | Later (diff) | |
download | 42-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_shoot.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/ft_shoot.c b/src/ft_shoot.c index 1797b2d..248ea6e 100644 --- a/src/ft_shoot.c +++ b/src/ft_shoot.c @@ -28,8 +28,8 @@ static void { while (++j < 4096) { - if (cl->sprites[i][j].s_pos_x == cl->rlist.sqy && - cl->sprites[i][j].s_pos_y == cl->rlist.sqx) + if (cl->sprites[i][j].s_pos_x == cl->rlist.sqx && + cl->sprites[i][j].s_pos_y == cl->rlist.sqy) { stop = 1; break ; @@ -39,7 +39,7 @@ static void break ; j = -1; } - cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] = '0'; + cl->mlist.map[cl->rlist.sqy][cl->rlist.sqx] = '0'; cl->sprites[i][j].s_pos_x = 0; cl->sprites[i][j].s_pos_y = 0; } @@ -48,8 +48,8 @@ static int8_t ft_weap_range(t_cub *cl) { if (cl->plist.handles_weapon == 0 && - sqrtf(powf(cl->plist.pos_x - cl->rlist.sqy, 2) - + powf(cl->plist.pos_y - cl->rlist.sqx, 2)) > 1.6) + sqrtf(powf(cl->plist.pos_x - cl->rlist.sqx, 2) + + powf(cl->plist.pos_y - cl->rlist.sqy, 2)) > 1.6) return (0); return (1); } @@ -60,13 +60,13 @@ static void 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.sqy += 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.sqx += cl->mlist.y_step; cl->rlist.side = 1; } } @@ -78,18 +78,18 @@ static void { ft_set_sq(cl); if (ft_ischarset(FT_CHRST_SPRITES, - cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy]) && ft_weap_range(cl)) + cl->mlist.map[cl->rlist.sqy][cl->rlist.sqx]) && ft_weap_range(cl)) { hit = 1; ft_hide_sprite(cl); } - else if (cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] == 'e' && + else if (cl->mlist.map[cl->rlist.sqy][cl->rlist.sqx] == 'e' && ft_weap_range(cl)) { hit = 1; ft_damage_bad_boy(cl); } - else if (cl->mlist.map[cl->rlist.sqx][cl->rlist.sqy] == '1') + else if (cl->mlist.map[cl->rlist.sqy][cl->rlist.sqx] == '1') hit = 1; } } @@ -104,10 +104,10 @@ void pl = &cl->plist; cl->rlist.x_ray_pos = pl->pos_y; cl->rlist.y_ray_pos = pl->pos_x; - 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; + 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); ft_hitscan(cl, 0); |