Está en la página 1de 1

INFORMATICA A. A. L.

E
static void Main(string[] args)
{
int y = 0;
int x = 0;
int diry = 1;
int dirx = 1;
DateTime ultimavez = DateTime.Now;
ConsoleKeyInfo tecla;
bool terminar = false;
Console.CursorVisible = true;
do
{
if (DateTime.Now > ultimavez.AddMilliseconds(500))
{
Console.Clear();
Console.SetCursorPosition(x, y);
x = x + dirx;
y = y + diry;
if (y <= 0)
{
diry = 1;
}
if (y >= Console.WindowHeight - 1)
{
diry = -1;
}
if (x <= 0)
{
dirx = 1;
}
if (x >= Console.WindowWidth - 1)
{
dirx = -1;
}
Console.Write("x");
ultimavez = DateTime.Now;

}
if(Console.KeyAvailable)
{
tecla = Console.ReadKey();
if(tecla.Key == ConsoleKey.Escape)
{
terminar = true;
}
}
} while(terminar == false);
}
}

También podría gustarte