-
Notifications
You must be signed in to change notification settings - Fork 0
/
cub3d_wall_facing.c
executable file
·65 lines (59 loc) · 2.35 KB
/
cub3d_wall_facing.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
54
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d_wall_facing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mg <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/21 16:38:50 by mg #+# #+# */
/* Updated: 2020/10/02 00:15:43 by mg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void c3d_wall_facing(t_param *cub3d)
{
if (cub3d->ray.angle == 0 || cub3d->ray.angle == (2 * M_PI))
cub3d->wall.facing = 'E';
else if (cub3d->ray.angle == M_PI_2)
cub3d->wall.facing = 'N';
else if (cub3d->ray.angle == M_PI)
cub3d->wall.facing = 'W';
else if (cub3d->ray.angle == (3 * M_PI_2))
cub3d->wall.facing = 'S';
else if (cub3d->ray.angle < M_PI_2 && cub3d->ray.angle > 0)
c3d_wall_facing_quadrant_1(cub3d);
else if (cub3d->ray.angle < M_PI && cub3d->ray.angle > M_PI_2)
c3d_wall_facing_quadrant_2(cub3d);
else if (cub3d->ray.angle < (3 * M_PI_2) && cub3d->ray.angle > M_PI)
c3d_wall_facing_quadrant_3(cub3d);
else if (cub3d->ray.angle < (2 * M_PI) && cub3d->ray.angle > (3 * M_PI_2))
c3d_wall_facing_quadrant_4(cub3d);
}
void c3d_wall_facing_quadrant_1(t_param *cub3d)
{
if (cub3d->wall.type == VERTICAL)
cub3d->wall.facing = 'E';
else if (cub3d->wall.type == HORIZONTAL)
cub3d->wall.facing = 'N';
}
void c3d_wall_facing_quadrant_2(t_param *cub3d)
{
if (cub3d->wall.type == VERTICAL)
cub3d->wall.facing = 'W';
else if (cub3d->wall.type == HORIZONTAL)
cub3d->wall.facing = 'N';
}
void c3d_wall_facing_quadrant_3(t_param *cub3d)
{
if (cub3d->wall.type == VERTICAL)
cub3d->wall.facing = 'W';
else if (cub3d->wall.type == HORIZONTAL)
cub3d->wall.facing = 'S';
}
void c3d_wall_facing_quadrant_4(t_param *cub3d)
{
if (cub3d->wall.type == VERTICAL)
cub3d->wall.facing = 'E';
else if (cub3d->wall.type == HORIZONTAL)
cub3d->wall.facing = 'S';
}