I want to make a game and I'd like to put a timer in it while it's running, a way in which the player can enter the desired duration and it would end the program at the end of that time. How can I fill the while condition in the following code, to achieve this?
ConsoleKeyInfo info;
jatek j = new jatek();
do
{
Console.Clear();
Console.WriteLine(j.Jatekter());
info = Console.ReadKey(true);
switch (info.Key)
{
case ConsoleKey.UpArrow: j.Mozgas(-1, 0); break;
case ConsoleKey.DownArrow: j.Mozgas(1, 0); break;
case ConsoleKey.LeftArrow: j.Mozgas(0, -1); break;
case ConsoleKey.RightArrow: j.Mozgas(0, 1); break;
case ConsoleKey.Escape: j.Vege = true; break;
}
} while ();