Ejemplo n.º 1
0
void			ft_map(char ***tetro, char **map, int i, int j)
{
	char	***tmp;
	int		count;

	count = 0;
	tmp = (char ***)malloc(sizeof(char **) * (j + 1));
	tmp[j] = NULL;
	while (map[count])
		count = count + 1;
	tmp = ft_malloctmp(tmp, count, j);
	ft_cpy(tmp, tetro, count, j);
	while (tetro[i] && i >= 0)
	{
		if (ft_checkmap(tetro, map, tmp, i))
			i = i + 1;
		else
		{
			ft_reload(tmp[i], tetro[i], count);
			i = i - 1;
		}
	}
	free(tmp);
	if (i < 0)
		ft_remap(tetro, map, i, j);
	else
		ft_printmap(map, j);
}
Ejemplo n.º 2
0
void	ft_execute(int fd)
{
	t_grid			*grid;
	t_point			point;

	grid = init_grid(fd);
	ft_set_params(grid);
	if (!g_errno)
		read_first_line(grid);
	if (!g_errno)
		ft_read(grid);
	if (!g_errno)
		test_full(grid);
	if (g_errno)
		ft_putstr("Map error\n");
	else
	{
		ft_remap(grid);
		point = find_max(grid);
		draw_square(grid, point.x, point.y, point.max);
		print_index(grid);
	}
	if (fd > 0)
		close(fd);
	free_grid(grid);
}