Exemple #1
0
int		main(int argc, char **argv)
{
	t_win	*window;
	t_cam	*cam;
	t_map	*map;

	/* Check argv */
	if (argc > 2 || argc == 1)
		ft_error("Too or not enough parameters in command line");
	/* Init Map */
	map = ft_init_map(argv[1]);
	/* Init Env */
	window = init_env();
	/* Init Camera */
	cam = ft_new_camera(map->start, M_PI / 2);

	/* Init img */
	window->img = init_img();

	mlx_do_key_autorepeaton(window->mlx);
	mlx_hook(window->win, 2, (1L << 0), ft_key_hook, window);
	mlx_expose_hook(window->win, ft_expose_hook, window);
	ft_draw_img();
	mlx_put_image_to_window(window->mlx, window->win, window->img->img, 0, 0);
	mlx_loop(window->mlx);


	/* Display view */
	/* Fini ! */
	return (0);
}
Exemple #2
0
int				ft_mouse_hook(int button, int x, int y, t_data *d)
{
	if (button == 1)
	{
		if (ft_in_button(d->buttons, x, y, d))
			ft_draw_buttons(d->buttons, d);
		ft_draw_img(d);
	}
	return (0);
}
Exemple #3
0
void							ft_rotate_right(t_data *d)
{
    t_object					*cam;

    cam = ft_get_camera(d->scenes[d->cs], &d->scenes[d->cs]->cam_num);
    cam->up.x -= 0.05;
    ft_get_n_vector(cam->up, &cam->up, 0);
    ft_render_camera(cam, d->scenes[d->cs]);
    ft_draw_img(d);
    ft_draw_buttons(d->buttons, d);
}
void							ft_move_backward(t_data *d)
{
	t_object					*cam;

	cam = ft_get_camera(d->scenes[d->cs], &d->scenes[d->cs]->cam_num);
	cam->p.x -= cam->n.x * SPEED;
	cam->p.y -= cam->n.y * SPEED;
	cam->p.z -= cam->n.z * SPEED;
	ft_render_camera(cam, d->scenes[d->cs]);
	ft_draw_img(d);
	ft_draw_buttons(d->buttons, d);
}