Cub3D
Loading...
Searching...
No Matches
set_wall_slice.c
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* set_wall_slice.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/08/26 22:34:03 by kamitsui #+# #+# */
9/* Updated: 2024/12/20 17:49:19 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "cub3d.h"
14
15#define MIN_PERP_WALL_DIST 1e-4
19void set_wall_slice(t_frame *frame, int x)
20{
21 t_wall_slice wall_slice;
22 double safe_perp_wall_dist;
23
24 safe_perp_wall_dist = frame->dda.perp_wall_dist;
25 if (frame->dda.perp_wall_dist < MIN_PERP_WALL_DIST)
26 safe_perp_wall_dist = MIN_PERP_WALL_DIST;
27 wall_slice.line_height = (int)(WIN_HEIGHT / safe_perp_wall_dist);
28 wall_slice.draw_start = -wall_slice.line_height / 2 + IMG_3D_HEIGHT / 2;
29 wall_slice.draw_end = wall_slice.line_height / 2 + IMG_3D_HEIGHT / 2;
30 if (wall_slice.draw_start < 0)
31 wall_slice.draw_start = 0;
32 if (wall_slice.draw_end >= WIN_HEIGHT)
33 wall_slice.draw_end = WIN_HEIGHT - 1;
34 frame->wall_slice = wall_slice;
35 (void)x;
36}
37 //debug_wall_slice(frame->debug.fd,
38 // frame->dda.perp_wall_dist, wall_slice, "set_wall_slice()");
single still image for render_frame
Definition type_cub3d.h:247
wall slice
Definition type_cub3d.h:191