-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotate_mouse.c
More file actions
32 lines (29 loc) · 1.48 KB
/
rotate_mouse.c
File metadata and controls
32 lines (29 loc) · 1.48 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rotate_mouse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bkarlida <bkarlida@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/26 19:49:16 by bkarlida #+# #+# */
/* Updated: 2023/09/03 15:48:28 by bkarlida ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void rotate_with_mouse(t_cub3d *game)
{
double old_dir_x;
double old_plane_x;
double rot_x;
rot_x = game->player.rot_speed * ((game->loc_x - game->m_old_pos_x) / 10.0);
old_dir_x = game->player.dir_x;
old_plane_x = game->player.plane_x;
game->player.dir_x = game->player.dir_x * cos(rot_x) - game->player.dir_y
* sin(rot_x);
game->player.dir_y = old_dir_x * sin(rot_x) + game->player.dir_y
* cos(rot_x);
game->player.plane_x = game->player.plane_x * cos(rot_x)
- game->player.plane_y * sin(rot_x);
game->player.plane_y = old_plane_x * sin(rot_x) + game->player.plane_y
* cos(rot_x);
}