Ejemplo n.º 1
0
void			ft_raycasting(t_env *e)
{
	t_rc	rc;
	int		x;

	x = 0;
	ft_drawskybox(e, -1, -1);
	while (x < rc.w)
	{
		ft_setrc(&rc, e, x);
		ft_setsideandstep(&rc);
		ft_dda(&rc, e);
		ft_perpwalandfriends(&rc);
		rc.lineheight = (int)abs((double)(rc.h) / rc.perpwalldist);
		rc.drawstart = -rc.lineheight / 2 + rc.h / 2;
		if (rc.drawstart < 0)
			rc.drawstart = 0;
		rc.drawend = rc.lineheight / 2 + rc.h / 2;
		if (rc.drawend >= rc.h)
			rc.drawend = rc.h - 1;
		while (rc.drawstart <= rc.drawend)
		{
			put_pixel_img(x, rc.drawstart, ft_setcolor(e, rc.orientation), e);
			rc.drawstart++;
		}
		x++;
	}
}
Ejemplo n.º 2
0
void		ft_raycaster(t_env *e)
{
	e->x = 0;
	while (e->x < WIDTH)
	{
		ft_initray(e);
		ft_dda(e);
		ft_line(e);
		ft_draw(e);
		e->x++;
	}
}
Ejemplo n.º 3
0
void		ft_print_wall(t_data *e)
{
	double	x;

	ft_init_vec(e);
	x = 0;
	while (x < e->w)
	{
		ft_ray_pos(e, x);
		ft_init_dda(e);
		ft_calc_dist(e);
		ft_dda(e);
		ft_correct_feye(e);
		ft_calc_hwall(e, x);
		x++;
	}
}
Ejemplo n.º 4
0
void	ft_raycast_wall(t_env *v, int x)
{
	CAMX = 2 * x / (double)WIDTH - 1;
	RAYPOSX = POSX;
	RAYPOSY = POSY;
	RAYDIRX = DIRX + PLANEX * CAMX;
	RAYDIRY = DIRY + PLANEY * CAMX;
	MAPX = (int)RAYPOSX;
	MAPY = (int)RAYPOSY;
	D_DELTAX = sqrt(1 + (RAYDIRY * RAYDIRY) / (RAYDIRX * RAYDIRX));
	D_DELTAY = sqrt(1 + (RAYDIRX * RAYDIRX) / (RAYDIRY * RAYDIRY));
	ft_calc_step(v);
//	dprintf(1, "debug1\n");
	ft_dda(v);
	ft_calc_dist(v);
//	dprintf(1, "x = %d lh = %d\n", x, LINEHEIGHT);
	ft_print_wall(v, x);
}
Ejemplo n.º 5
0
void	ft_corps(t_id *s)
{
    int x;

    x = -1;
    while (++x < W_X)
    {
        ft_start_initialisation(x, s);
        ft_ray_direction(s);
        ft_dda(s);
        ft_calc_pixl_place(s);
        ft_calc_floor_place(s);
        ft_draw_ceiling(x, s);
        if (x == W_X - 1)
            mlx_put_image_to_window(s->mlx, s->win, s->wall[13], MU, II);
        ft_draw_floor(x, s);
        ft_draw_walls(x, s);
    }
    mlx_put_image_to_window(s->mlx, s->win, s->img, 0, 0);
    ft_static_xpm(s);
}