-
Notifications
You must be signed in to change notification settings - Fork 0
/
cub3d_player_rotation.c
executable file
·28 lines (25 loc) · 1.31 KB
/
cub3d_player_rotation.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d_player_rotation.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mg <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/06 12:52:14 by mg #+# #+# */
/* Updated: 2020/10/07 23:08:38 by mg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void c3d_player_rotation(t_param *cub3d, int direction)
{
cub3d->player.angle += (double)M_PI / 36.0 * (double)direction;
cub3d->window.render = 1;
c3d_player_normalize_angle(cub3d);
}
void c3d_player_normalize_angle(t_param *cub3d)
{
if (cub3d->player.angle < 0)
cub3d->player.angle = (2 * M_PI) + cub3d->player.angle;
else if (cub3d->player.angle > (2 * M_PI))
cub3d->player.angle = cub3d->player.angle - (2 * M_PI);
}