Exemplo n.º 1
0
void	ft_resolve_a(t_stck *stck)
{
	int	i;

	ft_move(stck, stck->bgin);
	while (!ft_sorted_offset(stck))
	{
		i = 0;
		while (!ft_sorted_offset(stck) && i < stck->end - stck->bgin)
		{
			if (((t_ntry*)stck->a->content)->goal >
					((t_ntry*)stck->a->next->content)->goal)
				sa(stck);
			else
			{
				i++;
				if (i < stck->end - stck->bgin)
					ra(stck);
			}
		}
		if (!ft_sorted_offset(stck))
			ft_move(stck, 1 - i);
	}
	ft_unoffset(stck);
}
Exemplo n.º 2
0
int			key_hook(int keycode, t_wf *game)
{
	game = ft_move(keycode, game);
	if (keycode == ESC)
		exit (0);
	return (0);
}
Exemplo n.º 3
0
static int	ft_scanchr(unsigned int chr, t_elems **elem, t_output *output)
{
	int			index;
	t_output	*output_buf;

	if ((index = ft_searchtab(chr)) < 0)
		return (1);
	if (index == 0 || index == 1 || index == 2 || index == 3)
		ft_move(elem, index, output);
	else if (index == 4 || index == 5)
	{
		ft_deleteelem(elem, output->header);
		if (!(*elem) || !(output_buf =
			ft_managedisplay(ft_findstart((*elem), LIST, output->header),
				output->fd)))
			return (0);
		ft_memcpy(output, output_buf, sizeof(t_output));
		free(output_buf);
		ft_printconf(ft_findstart(*elem, DISPLAY, output->header), *elem,
					output);
	}
	else if (index == 6)
		return (0);
	return (1);
}
Exemplo n.º 4
0
int			key_hook(int keycode, t_mlx *mlx)
{
	double	tab1[7];
	double	tab2[7];

	mlx_clear_window(mlx->mlx, mlx->win);
	if (keycode == 53)
		exit(0);
	else if (keycode == 49 && mlx->f->nb == 1)
		ft_switch_julia(mlx, tab1, tab2, 0);
	else if (keycode == 69)
		mlx->iter = (mlx->iter < 8000) ? mlx->iter * 2 : mlx->iter;
	else if (keycode == 78)
		mlx->iter = (mlx->iter > 2) ? mlx->iter / 2 : mlx->iter;
	else if (keycode == 8)
		mlx->color++;
	else if (keycode == 3)
		mlx->freq = (mlx->freq < 200) ? mlx->freq * 2 : mlx->freq;
	else if (keycode == 2)
		mlx->freq = (mlx->freq > 0.1) ? mlx->freq / 2 : mlx->freq;
	key_hook2(keycode, mlx);
	ft_move(keycode, mlx);
	ft_draw(mlx);
	return (0);
}
Exemplo n.º 5
0
int		ft_expose_pytha(t_env *env)
{
	int		i;
	t_coord **carre;

	carre = (t_coord**)malloc(sizeof(t_coord*) * 4);
	i = -1;
	while (++i < 4)
		carre[i] = (t_coord*)malloc(sizeof(t_coord));
	carre[0]->x = ((WIDTH - 88) / 2) * env->zoom - env->movex;
	carre[0]->y = (HEIGHT - 89) * env->zoom - env->movey;
	carre[1]->x = ((WIDTH + 88) / 2) * env->zoom - env->movex;
	carre[1]->y = (HEIGHT - 89) * env->zoom - env->movey;
	carre[2]->x = ((WIDTH + 88) / 2) * env->zoom - env->movex;
	carre[2]->y = (HEIGHT - 1) * env->zoom - env->movey;
	carre[3]->x = ((WIDTH - 88) / 2) * env->zoom - env->movex;
	carre[3]->y = (HEIGHT - 1) * env->zoom - env->movey;
	ft_draw_pytha(carre, env, 0);
	i = -1;
	while (++i < 4)
		free(carre[i]);
	free(carre);
	i = -1;
	while (++i < 6)
		if (env->move[i])
			ft_move(env);
	return (0);
}
Exemplo n.º 6
0
int			ft_core(t_stack *stack_one, t_stack *stack_two, char *options)
{
    int		tmp[2];
    char	*sols;

    if (stack_one)
    {
        if ((tmp[0] = check_possibilities(stack_one, options, &sols)) != -1)
            return (tmp[0]);
        while (stack_one->next->next)
        {
            tmp[1] = ft_get_min(stack_one);
            tmp[0] = ft_direction(stack_one, tmp[1]) + (options[1] ? 10 : 0);
            ft_move(&stack_one, stack_two, tmp, &sols);
            ft_p(&stack_two, &stack_one, options[1] ? 1 : 0);
            if (options[1])
                ft_print_stack(stack_one, stack_two);
            sols = ft_strjoin_free(sols, " pb");
        }
        if (stack_one->number > stack_one->next->number)
            last(&stack_one, stack_two, options, &sols);
        ft_repush(&stack_two, &stack_one, &sols, options[1]);
        return (ft_display(sols, options, stack_one));
    }
    return (0);
}
Exemplo n.º 7
0
int		ft_key_hook(int keycode, t_env *e)
{
	if (e && (keycode == ESC))
	{
		write(1, "You've quit the program.\n", 25);
		exit(0);
	}
	else
	{
		if (e && (keycode == CTRL))
			e->img->angle += M_PI;
		else if (e && (keycode == 99))
			ft_get_color(e);
		else if (e && (keycode == 114))
		{
			e->img->pos_x = 1.0;
			e->img->pos_y = 1.0;
			e->img->angle = 0.0;
			e->img->color = 0x4B0082;
		}
		ft_move(e, keycode);
		ft_draw_wall(e);
	}
	return (0);
}
Exemplo n.º 8
0
int		ft_mouseforzoom(int bouton, int x, int y, t_env *env)
{
	if (x >= 0 && x <= env->win_h && y >= 0 &&
			y <= env->win_l && bouton == 6)
		ft_zoom(x, y, env);
	if (x >= 0 && x <= env->win_h && y >= 0 &&
			y <= env->win_l && bouton == 7)
		ft_dezoom(env);
	ft_move(env);
	return (0);
}
Exemplo n.º 9
0
void	ft_play(int x[2], int team, char *map, int sem_id)
{
	while (1)
	{
		ft_lock(sem_id);
		ft_putmap(map);
		if (ft_alone(map, team, x, sem_id))
			break ;
		ft_death(map, x, sem_id, team);
		ft_move(map, x, team);
		ft_putmap(map);
		ft_unlock(sem_id);
		sleep(1);
	}
}
Exemplo n.º 10
0
int	ft_loop_hook(t_env *e)
{
	int	x;

	if ((x = -1) && e->img.img != NULL)
	{
		mlx_destroy_image(e->mlx, e->img.img);
		e->img.img = NULL;
	}
	e->img.img = mlx_new_image(e->mlx, WIN_X, WIN_Y);
	while (++x < WIN_X)
		ft_raycast(e, x);
	ft_getframe(e);
	ft_move(e);
	mlx_put_image_to_window(e->mlx, e->win, e->img.img, 0, 0);
	return (0);
}
Exemplo n.º 11
0
int		ft_key(int key, t_env *env)
{
	env->imax = key == 69 ? env->imax + 1 : env->imax + 0;
	env->imax = key == 78 ? env->imax - 1 : env->imax + 0;
	env->y1 = key == 126 ? env->y1 + 0.1 : env->y1 + 0;
	env->y1 = key == 125 ? env->y1 - 0.1 : env->y1 + 0;
	env->x1 = key == 123 ? env->x1 + 0.1 : env->x1 + 0;
	env->x1 = key == 124 ? env->x1 - 0.1 : env->x1 + 0;
	env->zoom = key == 88 ? env->zoom + 50 : env->zoom + 0;
	env->zoom = key == 92 ? env->zoom - 80 : env->zoom + 0;
	if (key == 53)
	{
		mlx_destroy_image(env->mlx, env->adr);
		exit(1);
	}
	ft_move(env);
	return (0);
}
Exemplo n.º 12
0
void	ft_raycast(t_all *all)
{
	FN.img = mlx_new_image(FN.mlx, LARG, HAUT);
	FN.data = mlx_get_data_addr(FN.img, &FN.bpp, &FN.sizeline, &FN.endian);
	all->x = 0;
	while (all->x < LARG)
	{
		ft_init_ray(all, &RAY, &PLAYER);
		ft_calc_dest_dist(all, &RAY);
		ft_check_hit(all, &RAY);
		ft_calc_wall_dist(all, &RAY);
		ft_calc_height_line(&RAY);
		ft_check_wall_color(all, &RAY);
		ft_verline(&RAY, all);
		all->x++;
	}
	mlx_put_image_to_window(FN.mlx, FN.win, FN.img, 0, 0);
	ft_move(all, &PLAYER, &KEY);
}
Exemplo n.º 13
0
int		ft_key_hook(int kc, t_env *env)
{
	if (kc == 65307)
		ft_exit (env);
	if (kc == 45 || kc == 65453 || kc == 61 || kc == 65451 || kc == 65362
			|| kc == 65364 || kc == 65361 || kc == 65363 || kc == 65365
			|| kc == 65366 || kc == 65360 || kc == 65367 || kc == 114
			|| kc == 65455 || kc == 65450)
	{
		if (kc == 114)
			ft_displaysize(env);
		if (kc == 65367 && env->pxsize == 1)
			return (0);
		if (kc == 65367)
			env->pxsize--;
		ft_move(env, kc);
		ft_zoomnscale(env, kc);
		ft_replay(env);
	}
	return (0);
}
Exemplo n.º 14
0
int		ft_modifjulia(int x, int y, t_env *env)
{
	if (x >= 0 && x <= env->win_h && y >= 0 &&
			y <= env->win_l)
	{
		if (x >= 0 && x <= 100)
			env->mousex = (float)x / 100;
		if (x > 100 && x <= 200)
			env->mousex = (float)x / 180;
		if (x > 200 && x <= 300)
			env->mousex = (float)x / 250;
		if (x > 300 && x <= 400)
			env->mousex = (float)x / 300;
		if (x > 400 && x <= 500)
			env->mousex = (float)x / 350;
		if (x > 500 && x <= 600)
			env->mousex = (float)x / 400;
		env->mousey = 0.01;
	}
	ft_move(env);
	return (0);
}
Exemplo n.º 15
0
int				key_hook(t_all *all)
{
	int		ch;
	t_pos	dir;

	ch = getch();
	if (ch)
	{
		if (ch == ECHAP)
			return (-1);
		if (ch == K_LEFT)
			set_dir(&dir, -1, 0);
		else if (ch == K_RIGHT)
			set_dir(&dir, 1, 0);
		else if (ch == K_UP)
			set_dir(&dir, 0, -1);
		else if (ch == K_DOWN)
			set_dir(&dir, 0, 1);
		all->env.played = 1;
		if (ch == K_LEFT || ch == K_RIGHT || ch == K_UP
		|| ch == K_DOWN)
			ft_move(all, dir);
	}
}