New function convert tetri to bits ! BUT NOT WORKING :(
This commit is contained in:
@@ -6,12 +6,27 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/18 10:56:19 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/04/18 13:07:56 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fillit.h"
|
||||
|
||||
/*
|
||||
** !!! DELETE PRINT_BITS BEFORE EVAL !!!
|
||||
*/
|
||||
|
||||
void print_bits(short octet)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 1 << 16;
|
||||
while (i >>= 1)
|
||||
(octet & i) ? write(1, "1", 1) : write(1, "0", 1);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Function that parse a file and put each tetrimino in a linked list
|
||||
*/
|
||||
@@ -40,13 +55,36 @@ char **create_square(char *tetri)
|
||||
return (square);
|
||||
}
|
||||
|
||||
short create_tetribit(char *tetri)
|
||||
{
|
||||
short tetribit;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
tetribit = 0;
|
||||
while (tetri[i])
|
||||
{
|
||||
if (tetri[i] != '\n') // Pour comparer avec le tetri en char
|
||||
printf("%c", tetri[i]);
|
||||
if (tetri[i] == '#')
|
||||
{
|
||||
tetribit = tetribit | 1;
|
||||
tetribit <<= 1;
|
||||
}
|
||||
else
|
||||
tetribit <<= 1;
|
||||
i++;
|
||||
}
|
||||
return (tetribit);
|
||||
}
|
||||
|
||||
void parse_input(char *input)
|
||||
{
|
||||
static t_fillist *list = NULL;
|
||||
char tetri[20];
|
||||
int i;
|
||||
int j;
|
||||
char **test;
|
||||
short test; //DELETE BEFORE EVAL
|
||||
|
||||
i = 0;
|
||||
while (input[i])
|
||||
@@ -57,8 +95,11 @@ void parse_input(char *input)
|
||||
tetri[19] = '\0';
|
||||
if (check_tetri_errors(tetri))
|
||||
print_error("Error: Tetrimino not valid.");
|
||||
test = create_square(tetri);
|
||||
add_to_list(test, &list);
|
||||
test = create_tetribit(tetri);
|
||||
printf("\n");
|
||||
print_bits(test);
|
||||
//test = create_square(tetri);
|
||||
//add_to_list(test, &list);
|
||||
while (input[i] == '\n')
|
||||
i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user