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_extra_keys.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_extra_keys.c | 21 |
1 files changed, 13 insertions, 8 deletions
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 <libft.h> #include <pthread.h> +#include <stdio.h> 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); } |