void		fractal_choice(char **argv, t_struct *mystruct)
{
	if (ft_strequ(argv[1], "Julia") == 1)
	{
		mystruct->fracnum = 1;
		julia_init(mystruct);
		mlx_mouse_hook(mystruct->win, ft_zoom, mystruct);
		mlx_hook(mystruct->win, 6, (1L << 6), motion_julia, mystruct);
	}
	else if (ft_strequ(argv[1], "Mandel") == 1)
	{
		mystruct->fracnum = 2;
		mandel_init(mystruct);
		mlx_mouse_hook(mystruct->win, ft_zoom_mandel, mystruct);
		mlx_hook(mystruct->win, 6, (1L << 6), motion_mandel, mystruct);
	}
	else if (ft_strequ(argv[1], "Burning") == 1)
	{
		mystruct->fracnum = 3;
		burn_init(mystruct);
		mlx_mouse_hook(mystruct->win, ft_zoom_burning, mystruct);
		mlx_hook(mystruct->win, 6, (1L << 6), motion_burning, mystruct);
	}
	else
		error_arg();
}
Exemple #2
1
void	ft_initialisation(t_id *s)
{
    s->test = 0;
    s->sol = -1;
    s->gun = -1;
    s->plafond = -1;
    s->display = 0;
    s->planex = 0;
    s->planey = 0.66;
    s->dirx = -1;
    s->diry = 0;
    s->level = 0;
    s->img = mlx_new_image(s->mlx, W_X, W_Y);
    s->data = mlx_get_data_addr(s->img, &s->bit_per_pixel, &s->s_line,
                                &s->endian);
    s->bpp = s->bit_per_pixel / 8;
    ft_xpm_textures(s);
    ft_corps(s);
    mlx_mouse_hook(s->win, mouse_reaction_click, s);
    mlx_key_hook(s->win, key_reaction, s);
    mlx_hook(s->win, 17, (1L << 17), red_cross, s);
    mlx_hook(s->win, KEYPRESS, KEYPRESSMASK, ft_movement, s);
    mlx_hook(s->win, MOTIONNOTIFY, POINTERMOTIOMMASK, mouse_reaction, s);
    mlx_loop(s->mlx);
}
Exemple #3
0
int		main(void)
{
	int x;
	int y;
	int nb_it;
	double x_f;
	double y_f;
	double stepx;
	double stepy;
	t_env e;

	set_env(&e, "titre", WX, WY);
	x = 0;
	x_f = e.xmin;
	while (x <= WX)
	{
		y = 0;
		y_f = e.ymin;
		while (y <= WY)
		{
			nb_it = is_converg((mandelbrot), x_f, y_f);
			//	printf("val x_f = %lf, val de y_f = %lf, val de nb_it = %d\n", x_f, y_f, nb_it);
			if (nb_it < 1000)
				mlx_pixel_put_img(e.img, x, y, rainbow_gen(nb_it * 40));
			y++;
			y_f += e.stepy;
		}
		x_f += e.stepx;
		x++;
	}
	mlx_put_image_to_window(e.mlx, e.win, e.img, 0,0);
	mlx_mouse_hook(e.win, mouse_hook, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #4
0
static void	*start_fractal(void *data)
{
	t_thread_info		ti;
	int					frac_set;

	frac_set = (int)data;
	ti.blk.r = 0;
	ti.blk.g = 0;
	ti.blk.b = 0;
	ti.blk.alpha = 0;
	ti.c = (t_co *)ft_memalloc(sizeof(t_co));
	init_co_img(ti.c);
	ti.lock = 0;
	ti.show = 2;
	choose_set(frac_set, &ti);
	draw_set(ti.c->img, &ti.frac);
	IMG_TO_WINDOW(ti.c->mlx_ptr, ti.c->win_ptr, ti.c->img_ptr);
	mlx_hook(ti.c->win_ptr, KEYPRESS, 3, &handler_key, (void *)&ti);
	if (ti.frac.fract == JULIA)
		mlx_hook(ti.c->win_ptr, MOTNOTY, 1L << 6, &handler_julia, (void *)&ti);
	mlx_mouse_hook(ti.c->win_ptr, &handler_mouse, (void *)&ti);
	menu(ti.c);
	mlx_loop(ti.c->mlx_ptr);
	return (NULL);
}
Exemple #5
0
int		main(int argc, char **argv)
{
	t_img	*img;

	if (check_error(argc, argv[1]))
	{
		ft_putendl("Usage : ./fractol [Arg1]");
		ft_putendl("Arg1 being \"Julia\" or \"Mandelbrot\" or \"Ship\"");
		return (1);
	}
	if (!(img = init_image()))
		ft_mlx_error();
	if (argv[1][0] == 'm' || argv[1][0] == 'M')
		img->type = 'm';
	else if (argv[1][0] == 's' || argv[1][0] == 'S')
		img->type = 's';
	else if (argv[1][0] == 'j' || argv[1][0] == 'J')
		img->type = 'j';
	mlx_hook(img->win_ptr, 2, 1L << 8, grab_key, img);
	mlx_expose_hook(img->win_ptr, grab_expose, img);
	mlx_hook(img->win_ptr, MOTION_NOTIFY, POINTER_MOTION, motion_notify, img);
	mlx_mouse_hook(img->win_ptr, mouse_hook, img);
	mlx_loop(img->mlx_ptr);
	return (0);
}
Exemple #6
0
int			main(int ac, char **av)
{
	t_env	e;

	if (ac != 2)
		ft_error("Voir Usage a la compilation.");
	ft_getinput(&e, av[1]);
	if (!(e.mlx = mlx_init()))
		ft_error("mlx_init: Connexion au Xserver echouee.");
	if (!(e.win = mlx_new_window(e.mlx, WIDTH, HEIGHT, "fdf")))
		ft_error("mlx_new_window: La fenetre n'a pas pu etre creee.");
	if (!(e.img = mlx_new_image(e.mlx, WIDTH, HEIGHT)))
		ft_error("mlx_new_image: L'image n'a pas pu etre creee.");
	if (!(e.table = mlx_get_data_addr(e.img, &e.bpp, &e.size, &e.endian)))
		ft_error("mlx_get_data_addr: Les donnees n'ont pas pu etre lues.");
	e.zoom = 10;
	e.r = 0xcc;
	e.g = 0xcc;
	e.b = 0xcc;
	ft_center(&e, 0, 0, 0);
	ft_draw(&e);
	mlx_expose_hook(e.win, &ft_exposehook, &e);
	mlx_mouse_hook(e.win, &ft_mousehook, &e);
	mlx_hook(e.win, KeyPress, KeyPressMask, &ft_keypress, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #7
0
int		main(int argc, char **argv)
{
	t_env	e;
	t_cam	cam;
	t_set	settings;

	if (!argv[1] || argc != 2)
	{
		ft_putendl_fd("\033[1;33;40mWrong number of argument\033[0m", 2);
		ft_putstr_fd("Wolf3d : \n\t./wolf3d \033[1;32;40myour_map\033[0m", 2);
		ft_putendl_fd(" -> will start an arcade game with your map", 2);
		ft_putendl_fd("\t./wolf3d story -> will start the story mode", 2);
		return (0);
	}
	e.cam = &cam;
	e.set = &settings;
	e.file = ft_strdup(argv[1]);
	w_init(&e);
	w_check_out(&e);
	mlx_expose_hook(e.win, expose_hook, &e);
	mlx_hook(e.win, KeyPress, KeyPressMask, key_p, &e);
	mlx_hook(e.win, KeyRelease, KeyReleaseMask, key_r, &e);
	mlx_mouse_hook(e.win, mouse_hook, &e);
	mlx_loop_hook(e.mlx, &move, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #8
0
void			ft_burning_hub(mlx_t	*mlx)
{
	mlx->win_burning = mlx_new_window(mlx->mlx_ptr, WIDTH, HEIGHT, "burning");
	mlx_key_hook(mlx->win_burning, key_burning, mlx);	
	mlx_mouse_hook(mlx->win_burning, mouse_burning, mlx);
	mlx_expose_hook(mlx->win_burning, expose_burning, mlx);
}
Exemple #9
0
void		ft_mandelbrot(void)
{
	t_env	*e;
	int		bpp;
	int		ls;
	int		endian;

	e = (t_env *)malloc(sizeof(t_env));
	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, SIZE_W, SIZE_W, "fractal de Mandelbrot");
	bpp = 4;
	ls = 4 * SIZE_W;
	endian = 0;
	e->xmin = -2;
	e->xmax = 2;
	e->ymin = -2;
	e->ymax = 2;
	e->data = NULL;
	e->img = mlx_new_image(e->mlx, SIZE_W, SIZE_W);
	e->data = mlx_get_data_addr(e->img, &bpp, &ls, &endian);
	mlx_expose_hook(e->win, expose_hook, e);
	mlx_mouse_hook(e->win, mouse_hook, e);
	mlx_key_hook(e->win, key_hook, e);
	mlx_loop(e->mlx);
}
Exemple #10
0
void	init_hooks(t_env *e)
{
	mlx_hook(e->win, 2, (1L << 7), &key_hook, e);
	mlx_loop_hook(e->core, &loop_hook, e);
	mlx_expose_hook(e->win, &expose_hook, e);
	mlx_mouse_hook(e->win, &mouse_hook, e);
	mlx_hook(e->win, 6, (1L << 6), mouse_move, e);
}
Exemple #11
0
static void	set_hooks(t_env *w)
{
	mlx_expose_hook(w->win, expose_hook, w);
	mlx_mouse_hook(w->win, mouse_hook, w);
	mlx_hook(w->win, 2, 0, keypressed, w);
	mlx_hook(w->win, 3, 1, keyreleased, w);
	mlx_hook(w->win, 6, 1 << 6, motion_hook, w);
}
Exemple #12
0
int				main_loop(t_map *m)
{
	set_param(m);
	calculus(m);
	mlx_key_hook(m->win, &get_loop_key, m);
	mlx_mouse_hook(m->win, &get_loop_scroll, m);
	mlx_hook(m->win, 6, (1l << 6), &get_loop_mouse, m);
	mlx_loop(m->mlx);
	return (0);
}
Exemple #13
0
void	handle_second_win(void)
{
	static int i = 0;

	mlx_hook(g()->p2.win, 6, 64, &mouse_hook, &g()->p2);
	mlx_key_hook(g()->p2.win, key_hook, &g()->p2);
	mlx_mouse_hook(g()->p2.win, mouse2_hook, &g()->p2);
	mlx_expose_hook(g()->p2.win, expose_hook, &g()->p2);
	if (i == 0)
		first_display_secwin(&i);
}
Exemple #14
0
void		han_shot_first(t_init st, char *str)
{
	st = init_all(st, str);
	resolution(st);
	mlx_hook(st.win, 2, 1, key_hook, &st);
	if (ft_strcmp(str, "Julia") == 0)
		mlx_hook(st.win, 6, (1L << 6), motion_hook, &st);
	mlx_mouse_hook(st.win, mouse_hook, &st);
	mlx_put_image_to_window(st.mlx, st.win, st.link,
			st.pos_x_image, st.pos_y_image);
	mlx_loop(st.mlx);
}
Exemple #15
0
int		main(int argc, char **argv)
{
	t_env	e;

	e.mlx = mlx_init();
	e.win = mlx_new_window(e.mlx, 420, 420, "fenetre de fouuuuuuuuu !!!!!!");
	mlx_key_hook(e.win, key_hook, &e);
	mlx_expose_hook(e.win, expose_hook, &e);
	mlx_mouse_hook(e.win, mouse_hook, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #16
0
int				main(void)
{
	t_env		e;

	e.mlx = mlx_init();
	e.win = mlx_new_window(e.mlx, WIDTH, HEIGHT, TITLE);
	ft_init_env(&e);
	mlx_key_hook(e.win, ft_key_hook, &e);
	mlx_mouse_hook(e.win, ft_mouse_hook, &e);
	mlx_expose_hook(e.win, ft_expose_hook, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #17
0
void	ft_mlx(t_env *e)
{
	e->f = malloc(sizeof(t_img));

	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, WIDTH + (2 * OFF), HEIGHT + (2 * OFF), "triangle_try_angle");
	e->f->img = mlx_new_image(e->mlx, WIDTH + (2 * OFF), HEIGHT + (2 * OFF));
	e->f->d = mlx_get_data_addr(e->f->img, &e->f->bpp, &e->f->line_size, &e->f->endian);
	mlx_key_hook(e->win, key_hook, e);
	mlx_mouse_hook(e->win, mouse_hook, e);
	mlx_expose_hook(e->win, expose_hook, e);
	mlx_loop(e->mlx);
}
Exemple #18
0
void		ft_launch(t_param *p, char *file)
{
	if ((p->e.mlx = mlx_init()) == NULL)
		exit(ft_error("[Mlx init]: Initialisation impossible"));
	p->e.win = mlx_new_window(p->e.mlx, WIN_X, WIN_Y, p->file);
	p->e.img = mlx_new_image(p->e.mlx, WIN_X, WIN_Y);
	p->data = mlx_get_data_addr(p->e.img, &(p->bpp), &(p->sl), &(p->endian));
	ft_work(p, 0);
	mlx_mouse_hook(p->e.win, &ft_mouse_hook, p);
	mlx_expose_hook(p->e.win, &ft_expose_hook, p);
	mlx_key_hook(p->e.win, &ft_key_hook, p);
	mlx_loop(p->e.mlx);
}
Exemple #19
0
int		resolution(t_letubbies po)
{
	t_mlx	list;

	list = init_mlx(po);
	list.lp = put_gap_lpoint(list);
	ft_try(list);
	mlx_hook(list.win, 2, 1, key_hook, &list);
	mlx_mouse_hook(list.win, mouse_hook, &list);
	mlx_put_image_to_window(list.mlx, list.win, list.link,
			list.pos_x_image, list.pos_y_image);
	mlx_loop(list.mlx);
	return (0);
}
Exemple #20
0
int			main(int argc, char *argv[])
{
	t_all		*all;

	all = ft_malloc(sizeof(t_all));
	frac_init(all, argc, argv);
	mlx_hook(all->env.win, 6, (1L << 6), mouse_move, all);
	mlx_key_hook(all->env.win, key_hook, all);
	mlx_mouse_hook(all->env.win, mouse_hook, all);
	mlx_loop_hook(all->env.mlx, loop_hook, all);
	mlx_expose_hook(all->env.win, expose_hook, all);
	mlx_loop(all->env.mlx);
	return (0);
}
Exemple #21
0
int				main(int ac, char **av)
{
	t_env	e;

	parser(&e, ac, av);
	env_setup(&e);
	algorithm(&e);
	mlx_key_hook(e.win, key, &e);
	mlx_mouse_hook(e.win, mouse, &e);
	mlx_expose_hook(e.win, expose, &e);
	mlx_hook(e.win, MOTION_NOTIFY, POINTER_MOTION_MASK, motion_mouse, &e);
	mlx_loop(e.mlx);
	return (0);
}
void	map_processing(t_e *e)
{
	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, WIN_W, WIN_H, WIN_N);
	e->ima = mlx_new_image(e->mlx, WIN_W, WIN_H);
	e->ima_data = mlx_get_data_addr(
			e->ima, &(e->ima_bits), &(e->ima_line), &(e->ima_endi));
	e->grid = create_grid(e);
	reset(e);
	mlx_key_hook(e->win, key_hook, e);
	mlx_mouse_hook(e->win, mouse_hook, e);
	mlx_expose_hook(e->win, expose_hook, e);
	mlx_hook(e->win, 17, (1L << 17), &end_exe, e);
	mlx_hook(e->win, 2, (1L << 0), &key_hook_press, e);
	mlx_loop(e->mlx);
}
Exemple #23
0
int				main(int argc, char **argv)
{
	t_fract		f;

	ft_bzero(&f, sizeof(t_fract));
	get_args(argc, argv, &f);
	init_env(&f);
	if (getppid() == 0)
		usage();
	f.render_mode(&f);
	mlx_mouse_hook(f.win, &mouse_hook, &f);
	mlx_hook(f.win, KEY_PRESS, KEY_PRESS_MASK, key_hook, &f);
	mlx_hook(f.win, MOTION_NOTIFY, PTR_MOTION_MASK, motion_hook, &f);
	mlx_loop(f.mlx);
	mlx_destroy_window(f.mlx, f.win);
	return (0);
}
Exemple #24
0
int					main(int ac, char **av)
{
	t_frac			frac;

	if (ac >= 2)
		check_arg(av, &frac.img, &frac);
	else
	{
		cat_readme();
		return (0);
	}
	mlx_mouse_hook(frac.img.win, ft_mouse_hook, &frac);
	mlx_hook(frac.img.win, 2, 1, ft_key_press, &frac);
	mlx_hook(frac.img.win, MOTIONNOTIFY, POINTERMOTIONMASK, ft_move_mouse,
		&frac);
	mlx_loop(frac.img.mlx);
}
Exemple #25
0
int		main(int argc, char **argv)
{
	t_env env;

	if (argc != 2)
		print_usage();
	if (WINX <= 0 || WINY <= 0)
		exit(0);
	init_env(&env);
	init_fract(argv, &env);
	mlx_mouse_hook(env.win, my_mouse_hook, &env);
	mlx_key_hook(env.win, my_key_hook, &env);
	mlx_key_hook(env.winop, i_quit, &env);
	mlx_loop_hook(env.mlx, my_loop_hook, &env);
	mlx_hook(env.win, 6, (1L << 6), my_hook_events, &env);
	mlx_loop(env.mlx);
	return (0);
}
Exemple #26
0
int		main(int ac, char **av)
{
	t_env	e;

	init_var(ac, av, &e);
	e.mlx = mlx_init();
	if (e.mlx == NULL)
		exit(0);
	e.win = mlx_new_window(e.mlx, W_WIDTH, W_HEIGHT, "Fract'ol");
	e.img = mlx_new_image(e.mlx, W_WIDTH, W_HEIGHT);
	e.data = mlx_get_data_addr(e.img, &e.bpp, &e.sl, &e.endian);
	mlx_hook(e.win, MotionNotify, PointerMotionMask, mouse_move, &e);
	mlx_expose_hook(e.win, expose_hook, &e);
	mlx_mouse_hook(e.win, mouse_hook, &e);
	mlx_key_hook(e.win, key_hook, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #27
0
void		screen_init(t_box *box, int id)
{
	t_cmplx a;

	ft_bzero(&a, sizeof(t_cmplx));
	if (box->img != NULL)
		mlx_destroy_image(box->mlx, box->img);
	if (box->win != NULL)
		mlx_destroy_window(box->mlx, box->win);
	init(box, id);
	if (id == 1 || id == 3 || id == 5 || id == 7 || id == 9)
		print_mandelbrot(box, id);
	else if (id == 2 || id == 4 || id == 6 || id == 8 || id == 10)
		print_julia(box, id, &a);
	mlx_hook(box->win, 2, (1L << 0), command2, box);
	mlx_hook(box->win, 6, (1L << 6), mouse_command, box);
	mlx_mouse_hook(box->win, mouse_click, box);
	mlx_put_image_to_window(box->mlx, box->win, box->img, 0, 0);
}
Exemple #28
0
int			main(int ac, char **av)
{
	t_fract	e;

	if (ac == 2 && (e.fract = check_fract(av[1])))
	{
		var_init(&e);
		e.mlx = mlx_init();
		e.win = mlx_new_window(e.mlx, WIDTH, HEIGHT, "fractol");
		mlx_expose_hook(e.win, draw, &e);
		mlx_mouse_hook(e.win, zoom, &e);
		mlx_key_hook(e.win, key, &e);
		mlx_hook(e.win, 6, (1L << 6), mouse, &e);
		mlx_loop(e.mlx);
	}
	else
		display_params();
	return (0);
}
Exemple #29
0
int			main(int ac, char **av)
{
	int two_win;

	if (ac < 2)
		ft_error(INVALID_ARGZ);
	init_all();
	two_win = parse_params(av);
	init_mlx(two_win);
	mlx_hook(g()->p.win, 6, 64, &mouse_hook, &g()->p);
	mlx_key_hook(g()->p.win, key_hook, &g()->p);
	mlx_mouse_hook(g()->p.win, mouse2_hook, &g()->p);
	mlx_expose_hook(g()->p.win, expose_hook, &g()->p);
	if (two_win)
		handle_second_win();
	mlx_loop_hook(g()->e.mlx, loop_hook, &g()->cur);
	mlx_loop(g()->e.mlx);
	return (0);
}
Exemple #30
0
int			ft_init(int **val, int length, int width)
{
	t_coord	e;

	e.move_x = 0;
	e.move_y = 0;
	e.zoom = 0;
	e.t_val = val;
	e.length = length;
	e.width = width;
	e.val = ft_init_coord(e.t_val, e.length, e.width, &e);
	e.mlx = mlx_init();
	e.win = mlx_new_window(e.mlx, 2080, 1350, "fdf");
	mlx_expose_hook(e.win, &ft_expose_hook, &e);
	e.indice = mlx_key_hook(e.win, &ft_key_hook, &e);
	e.indice = mlx_mouse_hook(e.win, &ft_mouse_hook, &e);
	e.indice = mlx_loop(e.mlx);
	return (0);
}