diff options
-rw-r--r-- | src/ft_basic_keys.c | 20 | ||||
-rw-r--r-- | src/ft_castray_loop.c | 2 | ||||
-rw-r--r-- | src/ft_draw_sprite_extra.c | 7 | ||||
-rw-r--r-- | src/ft_extra_keys.c | 16 | ||||
-rw-r--r-- | src/ft_floor_cast_inits.c | 6 | ||||
-rw-r--r-- | src/ft_init_lists.c | 2 | ||||
-rw-r--r-- | src/ft_shoot.c | 4 |
7 files changed, 29 insertions, 28 deletions
diff --git a/src/ft_basic_keys.c b/src/ft_basic_keys.c index 2d029ff..48a1305 100644 --- a/src/ft_basic_keys.c +++ b/src/ft_basic_keys.c @@ -20,34 +20,34 @@ int const float move_speed = FT_MOVE_SPEED; pl = &clist->plist; - pl->pos_y += move_speed * pl->dir_y; + pl->pos_y += move_speed * -pl->dir_y; pl->pos_x += move_speed * pl->dir_x; clist->moves = 1; return (0); } int - ft_a_key(t_cub *clist) + ft_s_key(t_cub *clist) { t_player *pl; - const float move_speed = FT_STRAFE_SPEED; + const float move_speed = FT_MOVE_SPEED; pl = &clist->plist; - pl->pos_y += move_speed * -pl->dir_x; - pl->pos_x += move_speed * pl->dir_y; + pl->pos_y += move_speed * pl->dir_y; + pl->pos_x += move_speed * -pl->dir_x; clist->moves = 1; return (0); } int - ft_s_key(t_cub *clist) + ft_a_key(t_cub *clist) { t_player *pl; - const float move_speed = FT_MOVE_SPEED; + const float move_speed = FT_STRAFE_SPEED; pl = &clist->plist; - pl->pos_y += move_speed * -pl->dir_y; - pl->pos_x += move_speed * -pl->dir_x; + pl->pos_y += move_speed * -pl->dir_x; + pl->pos_x += move_speed * -pl->dir_y; clist->moves = 1; return (0); } @@ -60,7 +60,7 @@ int pl = &clist->plist; pl->pos_y += move_speed * pl->dir_x; - pl->pos_x += move_speed * -pl->dir_y; + pl->pos_x += move_speed * pl->dir_y; clist->moves = 1; return (0); } diff --git a/src/ft_castray_loop.c b/src/ft_castray_loop.c index 167ee1d..00cb589 100644 --- a/src/ft_castray_loop.c +++ b/src/ft_castray_loop.c @@ -47,7 +47,7 @@ void pl->cam_x = 2 * i / (float)(wl->x_size) - 1; cl->rlist.y_ray_pos = pl->pos_y; cl->rlist.x_ray_pos = pl->pos_x; - cl->rlist.y_ray_dir = pl->dir_y + pl->plane_x * + cl->rlist.y_ray_dir = -pl->dir_y + pl->plane_x * pl->cam_x; cl->rlist.x_ray_dir = pl->dir_x + pl->plane_y * pl->cam_x; diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index bb26cc2..e19fbf2 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -38,11 +38,12 @@ void static void ft_init_sprite(t_cub *cl, t_sprite *sprite) { - sprite->invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_x - - cl->plist.dir_y * cl->plist.plane_y); + sprite->invdet = 1.0 / + (cl->plist.plane_x * cl->plist.dir_x + - cl->plist.dir_y * cl->plist.plane_y); sprite->transformx = sprite->invdet * (cl->plist.dir_x * sprite->spritex - cl->plist.dir_y * sprite->spritey); - sprite->transformy = sprite->invdet * (-cl->plist.plane_y * sprite->spritex + sprite->transformy = sprite->invdet * (cl->plist.plane_y * sprite->spritex + cl->plist.plane_x * sprite->spritey); sprite->spritescreenx = (int)(cl->wlist.x_size / 2) * (1 + sprite->transformx / sprite->transformy); diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c index dba1026..1a81820 100644 --- a/src/ft_extra_keys.c +++ b/src/ft_extra_keys.c @@ -28,13 +28,13 @@ int pl = &clist->plist; sav_dir_y = pl->dir_y; - pl->dir_y = pl->dir_y * cos(rot_speed) - pl->dir_x * sin(rot_speed); - pl->dir_x = sav_dir_y * sin(rot_speed) + pl->dir_x * cos(rot_speed); + pl->dir_y = pl->dir_y * cos(-rot_speed) - pl->dir_x * sin(-rot_speed); + pl->dir_x = sav_dir_y * sin(-rot_speed) + pl->dir_x * cos(-rot_speed); sav_plane_x = pl->plane_x; pl->plane_x = pl->plane_x * cos(rot_speed) - pl->plane_y * sin(rot_speed); pl->plane_y = sav_plane_x * sin(rot_speed) + pl->plane_y * cos(rot_speed); - printf("dir_y %f\n", pl->dir_y); - printf("dir_x %f\n\n", pl->dir_x); + printf("dir_y %+f\n", pl->dir_y); + printf("dir_x %+f\n\n", pl->dir_x); return (0); } @@ -48,13 +48,13 @@ int pl = &clist->plist; sav_dir_y = pl->dir_y; - pl->dir_y = pl->dir_y * cos(-rot_speed) - pl->dir_x * sin(-rot_speed); - pl->dir_x = sav_dir_y * sin(-rot_speed) + pl->dir_x * cos(-rot_speed); + pl->dir_y = pl->dir_y * cos(rot_speed) - pl->dir_x * sin(rot_speed); + pl->dir_x = sav_dir_y * sin(rot_speed) + pl->dir_x * cos(rot_speed); sav_plane_x = pl->plane_x; pl->plane_x = pl->plane_x * cos(-rot_speed) - pl->plane_y * sin(-rot_speed); pl->plane_y = sav_plane_x * sin(-rot_speed) + pl->plane_y * cos(-rot_speed); - printf("dir_y %f\n", pl->dir_y); - printf("dir_x %f\n\n", pl->dir_x); + printf("dir_y %+f\n", pl->dir_y); + printf("dir_x %+f\n\n", pl->dir_x); return (0); } diff --git a/src/ft_floor_cast_inits.c b/src/ft_floor_cast_inits.c index 22c735a..022be1b 100644 --- a/src/ft_floor_cast_inits.c +++ b/src/ft_floor_cast_inits.c @@ -33,9 +33,9 @@ void void ft_floor_cast_inits(uint16_t y, t_ray *rl, t_cub *cl) { - rl->x_f_ray_dir = cl->plist.dir_y - cl->plist.plane_x; + rl->x_f_ray_dir = cl->plist.dir_y + cl->plist.plane_x; rl->y_f_ray_dir = cl->plist.dir_x - cl->plist.plane_y; - rl->x_f_ray_dir_bis = cl->plist.dir_y + cl->plist.plane_x; + rl->x_f_ray_dir_bis = cl->plist.dir_y - cl->plist.plane_x; rl->y_f_ray_dir_bis = cl->plist.dir_x + cl->plist.plane_y; rl->p = y - cl->wlist.y_size / 2; cl->plist.pos_z = 0.5 * cl->wlist.y_size; @@ -44,7 +44,7 @@ void (rl->x_f_ray_dir_bis - rl->x_f_ray_dir) / cl->wlist.x_size; cl->mlist.y_floor_step = rl->row_dist * (rl->y_f_ray_dir_bis - rl->y_f_ray_dir) / cl->wlist.x_size; - rl->x_floor = cl->plist.pos_y + rl->row_dist * rl->x_f_ray_dir; + rl->x_floor = -cl->plist.pos_y + rl->row_dist * rl->x_f_ray_dir; rl->y_floor = cl->plist.pos_x + rl->row_dist * rl->y_f_ray_dir; } diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 76b56e3..6ad56d1 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -47,7 +47,7 @@ t_player plist.start_x = 0; plist.start_y = 0; plist.cam_x = 0; - plist.dir_y = -1; + plist.dir_y = 1; plist.dir_x = 0; plist.plane_x = 0; plist.plane_y = 0.66; diff --git a/src/ft_shoot.c b/src/ft_shoot.c index 7336a80..ad5cfc8 100644 --- a/src/ft_shoot.c +++ b/src/ft_shoot.c @@ -104,8 +104,8 @@ void pl = &cl->plist; 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.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); |