merge fillit.c

This commit is contained in:
Gregory Tertyshny 2016-12-14 20:10:53 +02:00
commit 4f612f4447

View file

@ -20,47 +20,55 @@ void clear_map(t_map *map)
map->line[i++] = 0;
}
<<<<<<< HEAD:src/fillit.c
t_tetrominoes *convert_tetramino(char *s)
{
t_tetrominoes *res;
=======
void convert_tetramino(char *s, t_map *map, int index)
{
>>>>>>> a3800b97d2bd1e2713a340dc32de84e1b870b9a1:fillit.c
uint16_t temp;
int i;
int y;
int sharp_count;
<<<<<<< HEAD:src/fillit.c
res = (t_tetrominoes*)malloc(sizeof(t_tetrominoes));
res->offset_y = 0;
=======
map->figure[index].offset = 0;
sharp_count = 0;
>>>>>>> a3800b97d2bd1e2713a340dc32de84e1b870b9a1:fillit.c
i = 0;
y = 1;
while (i < 16)
while (i < 16 && sharp_count < 4)
{
temp = 0;
while (i < y * 4)
{
temp = temp << 1;
if (s[i++] == '#')
if (s[i++] == '#' && ++sharp_count)
temp = temp | 0x01;
}
temp = temp << 12;
res->line[y - 1] = temp;
map->figure[index].line[y - 1] = temp;
y++;
}
return (res);
map->figure[index].height = y - 1;
}
t_map *map_initialization(char **tetramino_table)
void map_initialization(char **tetramino_table, t_map *map)
{
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++);
convert_tetramino(*tetramino_table++, map, i++);
map->figure_amount = i;
map->size = ft_sqrt_ceil(i * 4);
clear_map(map);
return (map);
}
void insert_tetramino(t_map *map, int index)
@ -96,6 +104,31 @@ void erase_tetramino(t_map *map, int index)
}
}
<<<<<<< HEAD:src/fillit.c
//void algorithm(t_map *map)
//{
//}
=======
void shift_tetramino(t_map *map, int index)
{
//сделаю сдвиг фигуры вправо, если дошли до границы, то перемещу в начало следующего ряд и т.д.
}
void algorithm(t_map *map)
{
//тут у меня сейчас трабл с рекурсией
//не могу пока написать что-то годное
}
int main()
{
t_map map;
char** table;
table = read_from_file();
map_initialization(table, &map);
algoritm(&map);
print_result(&map);
return (0);
}
>>>>>>> a3800b97d2bd1e2713a340dc32de84e1b870b9a1:fillit.c