convert function is done

This commit is contained in:
Kolomiets Yaroslav 2016-12-14 13:04:07 +02:00
parent 01c3cb94d2
commit e6f030c38a

View file

@ -1,4 +1,6 @@
#include "fillit.h" #include "fillit.h"
#include <stdlib.h>
#include <stdio.h>
unsigned int ft_sqrt_ceil(unsigned int num) unsigned int ft_sqrt_ceil(unsigned int num)
{ {
@ -22,8 +24,28 @@ void clear_map(t_map *map)
t_tetraminos *convert_tetramino(char *s) t_tetraminos *convert_tetramino(char *s)
{ {
t_tetraminos *res; t_tetraminos *res;
uint16_t temp;
int i;
int y;
res = (t_tetraminos*)malloc(sizeof(t_tetraminos)); res = (t_tetraminos*)malloc(sizeof(t_tetraminos));
res->offset_y = 0;
i = 0;
y = 1;
while (i < 16)
{
temp = 0;
while (i < y * 4)
{
temp = temp << 1;
if (s[i++] == '#')
temp = temp | 0x01;
}
temp = temp << 12;
res->line[y - 1] = temp;
y++;
}
return (res); return (res);
} }