Пример #1
0
int				loop_hook(t_env *e)
{
	t_rgb	c;
	int		x;

	if (e->img.img != NULL)
	{
		//Changed form mlx_destroy_image to this.
		mlx_destroy_image(e->mlx, e->img.img);
		e->img.img = NULL;
	}
	e->img.img = mlx_new_image(e->mlx, WIN_WIDTH, WIN_HEIGH);
	x = 0;
	while (x < WIN_WIDTH)
	{
		init_ray(e, x);
		ray_dir(e);
		perform_dda(e);
		compute(e);
		colors(e, &c);
		draw_line(x, e, &c);
		x++;
	}
	get_time_frame(e);
	move(e);
	mlx_put_image_to_window(e->mlx, e->win, e->img.img, 0, 0);
	return (0);
}
Пример #2
0
static void		ray_len_from_curr_pos(t_map *map, double dx, double dy)
{
	map->ray->delta_dx = sqrt(1 + (map->ray->ray_dir_y * map->ray->ray_dir_y) /
								(map->ray->ray_dir_x * map->ray->ray_dir_x));
	map->ray->delta_dy = sqrt(1 + (map->ray->ray_dir_x * map->ray->ray_dir_x) /
								(map->ray->ray_dir_y * map->ray->ray_dir_y));
	if (map->ray->ray_dir_x < 0)
	{
		map->step_x = -1;
		map->ray->side_dist_x = (map->ray->ray_pos_x - map->map_x) * dx;
	}
	else
	{
		map->step_x = 1;
		map->ray->side_dist_x = (map->map_x + 1.0 - map->ray->ray_pos_x) * dx;
	}
	if (map->ray->ray_dir_y < 0)
	{
		map->step_y = -1;
		map->ray->side_dist_y = (map->ray->ray_pos_y - map->map_y) * dy;
	}
	else
	{
		map->step_y = 1;
		map->ray->side_dist_y = (map->map_y + 1.0 - map->ray->ray_pos_y) * dx;
	}
	perform_dda(map);
}
Пример #3
0
void			draw(t_env *e)
{
	e->x = 0;
	while (e->x < SCREEN_W)
	{
		draw_init(e);
		calculate_step_and_initial_side_dist(e);
		perform_dda(e);
		calculate_dist_projected(e);
		calculate_wall(e);
		if (e->textured_wall)
			texturing_calculations(e);
		else
			wall_color(e);
		draw_vertical_line(e);
		e->x++;
	}
	if (e->textured_wall && e->map.max_x > 25 && e->map.y > 25)
		draw_sprite(e);
}