More readable while loop and logic error in beginning of rush function

This commit is contained in:
Timo Schmidt 2023-03-19 20:36:14 +01:00
parent aa646ee8ef
commit 1e0ac10d42
1 changed files with 12 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/18 20:15:12 by jtorrez- #+# #+# */
/* Updated: 2023/03/19 19:30:25 by tischmid ### ########.fr */
/* Updated: 2023/03/19 20:18:40 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,12 +30,15 @@ void rush(int x, int y)
{
int i;
i = 0;
if (x < 1 && y < 1)
if (x < 1 || y < 1)
return ;
horiz_line(g_corners[0], g_horizontal, g_corners[1], x);
while (i++ < y - 2)
i = 0;
while (i < y - 2)
{
horiz_line(g_vertical, g_inside, g_vertical, x);
i = i + 1;
}
if (y > 1)
horiz_line(g_corners[3], g_horizontal, g_corners[2], x);
}
@ -47,10 +50,13 @@ void horiz_line(char left, char middle, char right, int width)
{
int i;
i = 0;
ft_putchar(left);
while (i++ < width - 2)
i = 0;
while (i < width - 2)
{
ft_putchar(middle);
i = i + 1;
}
if (width > 1)
ft_putchar(right);
ft_putchar('\n');