I am trying to practice what I have learned so far in c# by creating random applications. I have been working on a Console text adventure style game.
I created a method to clear the screen after a user hits any key.
This works but I have been looking for a way to be able to call my method at any time during the console application when the user hits a certain key. That way I don't have to randomly call this method as I write the code for the game and can give the player the ability to do it when they feel ready to.
For example, I want to be able to tell them from the very beginning something like hit c at any time during the game to clear the screen without messing up where they currently are in the game. Is there any way to accomplish this?
or another example would be something like hit h at any time during the program to check your health?
Any ideas on how to make that work or what I need to look into to make either of those ideas work would be greatly appreciated.
Thank You
static void clearScreen()
{
Console.WriteLine("\n Please press enter to clear the screen and continue");
Console.ReadLine();
Console.Clear();
}