-
Notifications
You must be signed in to change notification settings - Fork 0
/
key2.c
53 lines (48 loc) · 2.21 KB
/
key2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* key2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kristori <kristori@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/24 10:43:23 by kristori #+# #+# */
/* Updated: 2023/05/24 11:01:33 by kristori ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int ft_key_left_arrow(t_program *program)
{
double old_dir_x;
double old_plane_x;
old_dir_x = program->player.dir_x;
program->player.dir_x = program->player.dir_x
* cos(program->rot_speed) - program->player.dir_y
* sin(program->rot_speed);
program->player.dir_y = old_dir_x * sin(program->rot_speed)
+ program->player.dir_y * cos(program->rot_speed);
old_plane_x = program->player.plane_x;
program->player.plane_x = program->player.plane_x
* cos(program->rot_speed) - program->player.plane_y
* sin(program->rot_speed);
program->player.plane_y = old_plane_x * sin(program->rot_speed)
+ program->player.plane_y * cos(program->rot_speed);
return (0);
}
int ft_key_right_arrow(t_program *program)
{
double old_dir_x;
double old_plane_x;
old_dir_x = program->player.dir_x;
program->player.dir_x = program->player.dir_x
* cos(-program->rot_speed) - program->player.dir_y
* sin(-program->rot_speed);
program->player.dir_y = old_dir_x * sin(-program->rot_speed)
+ program->player.dir_y * cos(-program->rot_speed);
old_plane_x = program->player.plane_x;
program->player.plane_x = program->player.plane_x
* cos(-program->rot_speed) - program->player.plane_y
* sin(-program->rot_speed);
program->player.plane_y = old_plane_x * sin(-program->rot_speed)
+ program->player.plane_y * cos(-program->rot_speed);
return (0);
}