Exemplo n.º 1
0
t_piece	*ft_read(char *file, int *s, int caca)
{
	int		ret;
	int		fd;
	char	buff[BUFF_SIZE + 1];
	int		z;
	t_piece	*tetriminos;

	z = 0;
	tetriminos = malloc(sizeof(tetriminos) * 25);
	ft_bzero(buff, sizeof(buff));
	fd = ft_open_file(file);
	while ((ret = read(fd, buff, BUFF_SIZE)))
	{
		z >= 26 ? ft_error() : 0;
		ft_put_piece(buff, &tetriminos[z]);
		caca = ret;
		tetriminos[z].name = 'A' + z;
		ft_strclr(buff);
		z++;
	}
	caca == 21 ? ft_error() : 0;
	!tetriminos[0].piece[0][0] ? ft_error() : 0;
	*s = z;
	close(fd);
	ft_check_struct(tetriminos, z);
	return (tetriminos);
}
Exemplo n.º 2
0
Arquivo: fillit.c Projeto: smurfy92/42
void		ft_try_put_piece(t_map *map, t_piece *piece, int y, int x)
{
	int		ytmp;
	int		xtmp;

	ytmp = -1;
	if (piece->y_size + y < map->bestsize && piece->x_size + x < map->bestsize)
	{
		while (++ytmp < piece->y_size)
		{
			xtmp = -1;
			while (++xtmp < piece->x_size)
				if (map->actualcontent[y + ytmp][x + xtmp] != '.' &&
				piece->content[ytmp][xtmp] != '.')
					return ;
		}
		ft_put_piece(map, piece, y, x);
		ft_fillit(map);
		ft_clear_piece(map, piece, y, x);
	}
}