From 8a695d62dcb9b8783918263f962b986df20310f2 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 2 Apr 2020 14:24:57 +0200 Subject: Correct dir_x dir_y sqy sqx --- src/ft_extra_keys.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/ft_extra_keys.c') diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c index 03c6f75..dba1026 100644 --- a/src/ft_extra_keys.c +++ b/src/ft_extra_keys.c @@ -17,21 +17,24 @@ #include #include +#include int ft_left_key(t_cub *clist) { t_player *pl; - float sav_dir_x; + float sav_dir_y; float sav_plane_x; const float rot_speed = FT_ROT_SPEED; pl = &clist->plist; - sav_dir_x = pl->dir_x; - pl->dir_x = pl->dir_x * cos(rot_speed) - pl->dir_y * sin(rot_speed); - pl->dir_y = sav_dir_x * sin(rot_speed) + pl->dir_y * cos(rot_speed); + 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); 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); return (0); } @@ -39,17 +42,19 @@ int ft_right_key(t_cub *clist) { t_player *pl; - float sav_dir_x; + float sav_dir_y; float sav_plane_x; const float rot_speed = FT_ROT_SPEED; pl = &clist->plist; - sav_dir_x = pl->dir_x; - pl->dir_x = pl->dir_x * cos(-rot_speed) - pl->dir_y * sin(-rot_speed); - pl->dir_y = sav_dir_x * sin(-rot_speed) + pl->dir_y * cos(-rot_speed); + 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); 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); return (0); } -- cgit v1.2.3