87 lines
2.0 KiB
C
87 lines
2.0 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* printing.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/04/05 04:09:39 by tischmid #+# #+# */
|
|
/* Updated: 2023/04/05 06:54:58 by tischmid ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "printing.h"
|
|
|
|
void ft_putchar(char c)
|
|
{
|
|
write(1, &c, 1);
|
|
}
|
|
|
|
void ft_putstr(char *str)
|
|
{
|
|
while (*str)
|
|
ft_putchar(*str++);
|
|
}
|
|
|
|
void ft_putnbr(int nb)
|
|
{
|
|
if (nb > 9)
|
|
{
|
|
ft_putnbr(nb / 10);
|
|
ft_putchar(nb % 10 + '0');
|
|
}
|
|
else if (nb == INT_MIN)
|
|
{
|
|
ft_putnbr(nb / 10);
|
|
ft_putnbr(-(nb % 10));
|
|
}
|
|
else if (nb < 0)
|
|
{
|
|
ft_putchar('-');
|
|
ft_putnbr(-nb);
|
|
}
|
|
else
|
|
ft_putchar(nb % 10 + '0');
|
|
}
|
|
|
|
size_t ft_strlen(char const *str)
|
|
{
|
|
size_t size;
|
|
|
|
size = 0;
|
|
while (*str++)
|
|
++size;
|
|
return (size);
|
|
}
|
|
|
|
void print_map(t_map *map, int as_numbers)
|
|
{
|
|
int i;
|
|
int j;
|
|
|
|
ft_putstr("\nMap 2d:\n");
|
|
i = -1;
|
|
while (++i < map->meta.height)
|
|
{
|
|
j = -1;
|
|
while (++j < map->meta.width)
|
|
{
|
|
if (as_numbers)
|
|
{
|
|
ft_putnbr(map->data[i * map->meta.width + j]);
|
|
}
|
|
else
|
|
ft_putchar(map->data[i * map->meta.width + j]);
|
|
}
|
|
ft_putchar('\n');
|
|
}
|
|
}
|
|
// ft_putstr("Map Meta:\n\tEmpty char: ");
|
|
// ft_putchar(map->meta.empty);
|
|
// ft_putchar('\n');
|
|
// ft_putstr("\tObstacle char: ");
|
|
// ft_putchar(map->meta.obstacle);
|
|
// ft_putchar('\n');
|
|
// ft_putstr("\tFull char: ");
|
|
// ft_putchar(map->meta.full);
|