I have a problem executing a function in console, I want to make a face move from right to left but the movement does not run when I add the function of the eyes, it was my logic to put two functions apart and not only in one.
static void Main(string[] args)
{
while (true)
{
int i;
for (i = 1; i < 60; i++)
{
Console.ForegroundColor = ConsoleColor.Green;
dibujarRectangulo(9, 6, i, 1);
dibujarOjos(i + 1, 2);
System.Threading.Thread.Sleep(10);
Console.ForegroundColor = Console.BackgroundColor;
i -= 1;
dibujarRectangulo(9, 6, i, 1);
}
for (i = 60; i > 5; i--)
{
Console.ForegroundColor = ConsoleColor.Green;
dibujarRectangulo(9, 6, i, 1);
System.Threading.Thread.Sleep(10);
Console.ForegroundColor = Console.BackgroundColor;
dibujarRectangulo(9, 6, i, 1);
}
Console.ReadKey(true);
}
}
static void dibujarRectangulo(int ancho, int alto, int x, int y)
{
int cont = 0;
while (cont < ancho)
{
Console.SetCursorPosition(x + cont, y);
Console.Write("-");
Console.SetCursorPosition(x + cont, y + alto);
Console.Write("-");
cont++;
}
cont = 0;
while(cont < alto)
{
Console.SetCursorPosition(x, y + cont);
Console.Write("|");
Console.SetCursorPosition(x + ancho, y + cont);
Console.Write("|");
cont++;
}
}
static void dibujarOjos(int x, int y)
{
while (true)
{
Console.SetCursorPosition(3, 2);
Console.Write("■");
}
}
As you can see, the graphic does not move when I add the function of to draw Eyes , what problem do I have ?, in advance thank you very much for the help.