aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_extra_keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_extra_keys.c')
-rw-r--r--src/ft_extra_keys.c39
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)