From 3831ffb031bd236cba9eedd2b6dc24a6d9bff515 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 14 Feb 2020 00:04:37 +0100 Subject: Added turn around keys --- src/ft_extra_keys.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/ft_extra_keys.c') diff --git a/src/ft_extra_keys.c b/src/ft_extra_keys.c index 5bbb4b4..c920b48 100644 --- a/src/ft_extra_keys.c +++ b/src/ft_extra_keys.c @@ -1,5 +1,44 @@ #include #include +#include + +int8_t + ft_left_key(t_cub *clist) +{ + t_player *pl; + float sav_dir_x; + float sav_plane_x; + float rot_speed; + + pl = clist->plist; + rot_speed = 0.3; + 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_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); + return (0); +} + +int8_t + ft_right_key(t_cub *clist) +{ + t_player *pl; + float sav_dir_x; + float sav_plane_x; + float rot_speed; + + pl = clist->plist; + rot_speed = 0.3; + 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_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); + return (0); +} int8_t ft_f1_key(t_cub *clist) -- cgit v1.2.3