-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrays_methods.c
48 lines (43 loc) · 1.59 KB
/
rays_methods.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rays_methods.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahamdaou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/07 12:52:55 by ahamdaou #+# #+# */
/* Updated: 2021/01/22 18:54:10 by ahamdaou ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void rays_render(void)
{
t_point p0;
t_point p1;
int col;
if (g_pref.is_minimap_enabled == 0)
return ;
p0.x = g_player.x * g_game.minimap_scale;
p0.y = g_player.y * g_game.minimap_scale;
col = -1;
while (++col < g_game.num_rays)
{
p1.x = rays()[col]->wall_hit_x * g_game.minimap_scale;
p1.y = rays()[col]->wall_hit_y * g_game.minimap_scale;
line(p0, p1, COLOR_GREEN);
}
}
void cast_all_rays(void)
{
float ray_angle;
int col;
ray_angle = g_player.rotation_angle - (FOV_ANGLE / 2);
col = -1;
while (++col < g_game.num_rays)
{
rays()[col]->ray_angle = normalize_angle(ray_angle);
set_ray_direction(rays()[col]);
cast(rays()[col]);
ray_angle += FOV_ANGLE / g_game.num_rays;
}
}