示例#1
0
void	start_loop(t_player *pl)
{
	int		x;

	ft_bzero(pl->str, WIDTH * 4 * HEIGHT);
	x = -1;
	while (++x < WIDTH)
	{
		// printf("%d ", x);
		pl->x_camera = 2 * x / (double)WIDTH - 1;
		pl->ray_x_dir = pl->x_dir + pl->x_plane * pl->x_camera;
		pl->ray_y_dir = pl->y_dir + pl->y_plane * pl->x_camera;
		pl->x_map = (int)pl->x_pos;
		pl->y_map = (int)pl->y_pos;
		pl->delta_x_dist = fabs(1 / pl->ray_x_dir);
		pl->delta_y_dist = fabs(1 / pl->ray_y_dir);
		calculate_step_and_initial_side(pl);
		loop_while(pl);
		calculate_distance(pl);
		color_and_draw(x, pl);
	}
	pl->a = mlx_put_image_to_window(pl->mlx, pl->win, pl->img, 0, 0);
	pl->old_time = pl->new_time;
	// printf("%lu\n", pl->old_time);
	pl->new_time = clock();
	// printf("%lu\n", pl->new_time);
	pl->frame_time = (double)(pl->old_time - pl->new_time) / 500000.0;
	pl->move_speed = pl->frame_time * 0.0000000000001;
	printf("%f\n", pl->move_speed);
	pl->rot_speed = pl->frame_time * 3.0;


	// printf("%lu\n", clock()); 
}
示例#2
0
int main(int argc, char *argv[])
{
    printf("%d\n", loop_while(atoi(argv[1]), 16));
    return 0;
}