-
Notifications
You must be signed in to change notification settings - Fork 1
/
casting_rays.c
49 lines (44 loc) · 1.73 KB
/
casting_rays.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* casting_rays.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wzakkabi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/01 04:09:51 by wzakkabi #+# #+# */
/* Updated: 2023/12/02 22:09:32 by wzakkabi ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
double hm_px_bw_pyr_and_wall(t_map *map, double rayangle, int i)
{
float xdistance;
float ydistance;
angle_facing(map->wall3d->a_f, rayangle);
ydistance = find_y_horztouch(map, rayangle, map->wall3d->a_f);
xdistance = find_x_verticletouch(map, rayangle, map->wall3d->a_f);
if (ydistance < xdistance + 0.9)
{
return (ydistance);
}
map->wall3d->x_vertical[i] = true;
return (xdistance);
}
void cast_rays(t_map *map)
{
double rayangle;
int i;
rayangle = make_angle_postive(map->plr->retactionangle
- (map->plr->fovue_angle / 2));
i = 0;
while (i < map->plr->num_arys)
{
map->wall3d->rays_angle[i] = rayangle;
map->wall3d->x_vertical[i] = false;
map->wall3d->small_distance[i] = hm_px_bw_pyr_and_wall(map,
rayangle, i);
rayangle = make_angle_postive(rayangle + (map->plr->fovue_angle
/ map->plr->num_arys));
i++;
}
}