fonction print_final_map fonctionne mais backtracking bug..

This commit is contained in:
Hugo LAMY
2019-05-03 16:06:11 +02:00
parent bd38cd52ed
commit 671585098f
4 changed files with 21 additions and 25 deletions

32
print.c
View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */
/* Updated: 2019/05/03 14:19:51 by hulamy ### ########.fr */
/* Updated: 2019/05/03 16:05:19 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -36,7 +36,7 @@ void print_bits(unsigned int bits, int size)
** Print a map of height and width
*/
void print_map(unsigned int *tab, int width, int height)
void print_map(unsigned int *tab, int width, int height, char letter)
{
int i;
unsigned int mask;
@@ -50,7 +50,7 @@ void print_map(unsigned int *tab, int width, int height)
{
if (i && !(i % width))
ft_putchar('\n');
tab[i / 32] & (1 << (31 - i % 32)) ? ft_putchar('#') : ft_putchar('.');
tab[i / 32] & (1 << (31 - i % 32)) ? ft_putchar(letter) : ft_putchar('.');
ft_putchar(' ');
i++;
}
@@ -63,7 +63,7 @@ void print_map(unsigned int *tab, int width, int height)
void print_final_map(t_fillist *list, int size)
{
// unsigned int print;
unsigned int print; // DEBUG
t_fillist *tmp;
char *map;
int i;
@@ -71,9 +71,9 @@ void print_final_map(t_fillist *list, int size)
map = (char *)malloc(sizeof(*map) * (size * size + 1));
map[size*size] = '\0';
// i = -1;
// while (++i < size * size)
// map[i] = '.';
i = -1;
while (++i < size * size)
map[i] = '.';
tmp = list;
while (tmp)
{
@@ -81,19 +81,15 @@ void print_final_map(t_fillist *list, int size)
i = -1;
while (++i < tmp->width * tmp->height)
{
// ft_putchar('\n');
// print = tmp->tetribit << 16;
// print_map(&print, tmp->width, tmp->height);
// print_bits(tmp->tetribit, 16);
// print_bits(1 << (15 - i), 16);
// (1 >> i & tmp->tetribit) ? ft_putchar('1') : ft_putchar('.');
if (i && i + 1 % tmp->width == 0)
j += size;
if (i && i % tmp->width == 0)
j += size - tmp->width;
if (1 << (15 - i) & tmp->tetribit)
map[tmp->position + i + j] = tmp->letter;
else
map[tmp->position + i + j] = '.';
map[tmp->position + i + j - 1] = tmp->letter;
}
ft_putstr("position: "); ft_putnbrendl(tmp->position); // DEBUG
print = tmp->tetribit << 16; // DEBUG
print_map(&print, tmp->width, tmp->height, tmp->letter); // DEBUG
ft_putchar('\n'); // DEBUG
tmp = tmp->next;
}
i = -1;