fillit/fillit.c
2016-12-14 12:06:38 +02:00

43 lines
661 B
C

#include "fillit.h"
unsigned int ft_sqrt_ceil(unsigned int num)
{
int i;
i = 1;
while (i * i < num)
i++;
return (i);
}
void clear_map(t_map *map)
{
int i;
i = 0;
while (i < 16)
map->line[i++] = 0;
}
t_tetraminos *convert_tetramino(char *s)
{
t_tetraminos *res;
res = (t_tetraminos*)malloc(sizeof(t_tetraminos));
return (res);
}
t_map *map_initialization(char **tetramino_table)
{
t_map *map;
unsigned int i;
map = (t_map*)malloc(sizeof(t_map));
i = 0;
while (*tetramino_table)
map->figure[i++] = convert_tetramino(*tetramino_table++);
map->figure_amount = i;
map->size = ft_sqrt_ceil(i * 4);
clear_map(map);
return (map);
}