aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_shoot.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_shoot.c')
-rw-r--r--src/ft_shoot.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/ft_shoot.c b/src/ft_shoot.c
index 7f12eb6..dbd8862 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.3)
+ 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,39 +78,36 @@ 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;
}
}
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.y_ray_pos = pl->pos_y;
+ cl->rlist.x_ray_pos = pl->pos_x;
+ cl->rlist.y_ray_dir = -pl->dir_y;
+ cl->rlist.x_ray_dir = pl->dir_x;
+ cl->rlist.sqy = (uint64_t)cl->rlist.y_ray_pos;
+ cl->rlist.sqx = (uint64_t)cl->rlist.x_ray_pos;
ft_detection_init_x(cl);
ft_detection_init_y(cl);
ft_hitscan(cl, 0);