17 if (ray_cast.next_distance.x < ray_cast.next_distance.y)
18 return (ON_VERTICAL_LINE);
20 return (ON_HORIZONTAL_LINE);
25 return (map->data[ray_cast->grid.y][ray_cast->grid.x] ==
'1');
28static void move_next_grid_line(
t_ray_cast *ray_cast,
int type)
30 if (type == ON_VERTICAL_LINE)
32 ray_cast->next_distance.x += ray_cast->delta_distance.x;
33 ray_cast->grid.x += ray_cast->step_dir.x;
37 ray_cast->next_distance.y += ray_cast->delta_distance.y;
38 ray_cast->grid.y += ray_cast->step_dir.y;
42static double calculate_distance(
t_ray_cast ray_cast,
int type)
44 if (type == ON_VERTICAL_LINE)
45 return (ray_cast.next_distance.x - ray_cast.delta_distance.x);
47 return (ray_cast.next_distance.y - ray_cast.delta_distance.y);
56void perform_dda(
t_frame *frame,
int x)
65 type = get_line_type(frame->ray_cast);
66 move_next_grid_line(&frame->ray_cast, type);
67 hit = is_hit_wall(frame->map, &frame->ray_cast);
69 frame->dda.type_of_grid_line = type;
70 frame->dda.perp_wall_dist = calculate_distance(frame->ray_cast, type);
single still image for render_frame