diff options
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); } |