I am making a small console application game in C#. The thing is, you have to run around and collect gold. You have to do it under 1 minute otherwise you die. I made it work the way that I have made an enum including: Runs, Won, Lost, Ends statements. The main loop runs while the game state of the game is: Runs. Something like:
switch (...) {
case PlayGame:
Console.Clear();
GameWorld gameWorld = new GameWorld();
gameWorld.Update();
while (gameWorld.GameState == GameState.Runs) {
gameWorld.PlayerMovement();
gameWorld.Update();
}
break;
case ...
}
Now everything works fine.. The last thing is, that I have to make this "timer", that would count from 1 to 60 seconds and also print it on the screen at the given coordinates. I tried doing it many different ways. For example I made a method inside the GameWorld class (that is where I have the sort of core of the game) and called it Time. I made a variable Time and assigned the value of 60 to it. Then I made a for loop which set the cursor at the given coordinates, wrote the value which was raising with every loop and set Thread.Sleep(1000); as the last thing .. That basically added 1 to the value every second untill it got to 59. Now the thing is, that when I ran this method at the main loop (while), it counted to 60 seconds first and then it ran anything below it. The same thing was happening when I ran it below all the commands in the while loop. Do you guys have any idea how could I make that "countdown" run side by side with running main loop? Thank you for your answers and time!