list s'imprime dans main

This commit is contained in:
Hugo LAMY
2019-05-17 18:43:33 +02:00
6 changed files with 121 additions and 151 deletions

41
print.c
View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */
/* Updated: 2019/05/08 19:46:03 by vmanzoni ### ########.fr */
/* Updated: 2019/05/17 17:24:54 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -31,30 +31,6 @@ void print_bits(unsigned int bits, int size)
write(1, "\n", 1);
}
/*
** DELETE BEFORE EVAL - TEST FUNCTION
** Prints a tetri from its bit form
*/
void print_tetri(unsigned int bits, int size)
{
unsigned int mask;
short i;
i = 0;
mask = 1 << (size - 1);
while (mask)
{
if (i % 4 == 0)
write(1, "\n", 1);
(bits & mask) ? write(1, "#", 1) : write(1, ".", 1);
write(1, " ", 1);
mask >>= 1;
i++;
}
write(1, "\n", 1);
}
/*
** DELETE BEFORE EVAL - TEST FUNCTION
** Print a map of height and width
@@ -85,9 +61,8 @@ void print_map(unsigned int *tab, int width, int height, char letter)
** Print the final map with the letters
*/
void print_final_map(t_fillist *list, int size)
void print_final_map(t_fillist *list, int size, int flag) // DEBUG flag vaut 0 pour imprimer comme rendu et 1 pour imprimer en couleur
{
// unsigned int print; // DEBUG
t_fillist *tmp;
char *map;
int i;
@@ -107,7 +82,7 @@ void print_final_map(t_fillist *list, int size)
{
if (i && i % tmp->width == 0)
j += size - tmp->width;
if (1 << (15 - i) & tmp->tetribit && tmp->position != -1) // DEBUG "&& tmp->position != -1" pour imprimer les bonnes lettres au coours du debug
if (1 << (15 - i) & tmp->tetribit/* && tmp->test == 1*/) // DEBUG "&& tmp->position != -1" pour imprimer les bonnes lettres au coours du debug
map[tmp->position + i + j - 1] = tmp->letter;
}
tmp = tmp->next;
@@ -117,9 +92,13 @@ void print_final_map(t_fillist *list, int size)
{
if (i && i % size == 0)
ft_putchar('\n');
ft_putchar(map[i]);
// ft_put_tetri_color(map[i]);
// ft_putchar(' ');
if (flag == 0) // DEBUG imprim comme rendu
ft_putchar(map[i]);
else // DEBUG imprim avec couleurs
{
ft_put_tetri_color(map[i]);
ft_putchar(' ');
}
}
ft_putchar('\n');
}