diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-02-14 00:04:37 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-02-14 00:04:37 +0100 |
commit | 3831ffb031bd236cba9eedd2b6dc24a6d9bff515 (patch) | |
tree | acc698bc7a81303f5f2206c8e5446d4379235610 /src/ft_extra_keys.c | |
parent | Less retarded Makefile (diff) | |
download | 42-cub3d-3831ffb031bd236cba9eedd2b6dc24a6d9bff515.tar.gz 42-cub3d-3831ffb031bd236cba9eedd2b6dc24a6d9bff515.tar.bz2 42-cub3d-3831ffb031bd236cba9eedd2b6dc24a6d9bff515.tar.xz 42-cub3d-3831ffb031bd236cba9eedd2b6dc24a6d9bff515.tar.zst 42-cub3d-3831ffb031bd236cba9eedd2b6dc24a6d9bff515.zip |
Added turn around keys
Diffstat (limited to 'src/ft_extra_keys.c')
-rw-r--r-- | src/ft_extra_keys.c | 39 |
1 files changed, 39 insertions, 0 deletions
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 <cub3d.h> #include <stdint.h> +#include <math.h> + +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) |