static void Main() { ConsoleKey gameChoice; do { Console.Title = "Arcade"; Console.CursorVisible = false; Console.Clear(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Welcome to the arcade"); Console.WriteLine("Choose a game!\n"); Console.WriteLine("1 - Snake"); Console.WriteLine("2 - Doom"); Console.WriteLine("3 - Minecraft"); // Console.WriteLine("4 - Pathfinder"); Console.WriteLine("\nEscape - Exit"); gameChoice = Console.ReadKey().Key; if (gameChoice == ConsoleKey.D1) { do { int highscore = 0; if (File.Exists("Highscore.TXT")) { using (StreamReader sw = new StreamReader("Highscore.TXT")) highscore = Convert.ToInt16(sw.ReadLine()); } else { using (StreamWriter sw = new StreamWriter("Highscore.TXT")) sw.WriteLine(highscore); } Console.Clear(); Snake snake = new Snake(); snake.Start(); do { snake.Update(); System.Threading.Thread.Sleep(1000 / 16); } while (snake.gameEnded == false); Console.Clear(); Console.WriteLine("Game Over!"); if (snake.score > highscore) { highscore = snake.score; Console.WriteLine("New Highscore!"); using (StreamWriter sw = new StreamWriter("Highscore.TXT")) sw.WriteLine(highscore); } Console.WriteLine("\nScore: " + snake.score); Console.WriteLine("Highscore: " + highscore); Console.WriteLine("\nPress Enter to play again"); } while (Console.ReadKey().Key == ConsoleKey.Enter); } if (gameChoice == ConsoleKey.D2) { Console.Clear(); Doom doom = new Doom(); doom.Start(); do { doom.Update(); //System.Threading.Thread.Sleep(1000 / 60); } while (!doom.gameEnded); } if (gameChoice == ConsoleKey.D3) { Console.Clear(); Minecraft minecraft = new Minecraft(); minecraft.Start(); do { minecraft.Update(); System.Threading.Thread.Sleep(1000 / 60); } while (!minecraft.gameEnded); } /*if (gameChoice == ConsoleKey.D4) * { * Console.Clear(); * Pathfinder pathfinder = new Pathfinder(); * pathfinder.Start(); * do * { * pathfinder.Update(); * //System.Threading.Thread.Sleep(1000 / 60); * } while (!pathfinder.gameEnded); * }*/ } while (gameChoice != ConsoleKey.Escape); }
static void Main() { ConsoleKey gameChoice; do { Console.Clear(); Console.WriteLine("Welcome to the arcade"); Console.WriteLine("Choose a game!\n"); Console.WriteLine("1 - Snake"); Console.WriteLine("2 - Doom"); Console.WriteLine("\nEscape - Exit"); gameChoice = Console.ReadKey().Key; if (gameChoice == ConsoleKey.D1) { do { int highscore = 0; if (File.Exists("Highscore.TXT")) { using (StreamReader sw = new StreamReader("Highscore.TXT")) highscore = Convert.ToInt16(sw.ReadLine()); } else { using (StreamWriter sw = new StreamWriter("Highscore.TXT")) sw.WriteLine(highscore); } Console.Clear(); Snake snake = new Snake(); snake.Start(); do { snake.Update(); System.Threading.Thread.Sleep(1000 / 16); } while (snake.gameEnded == false); Console.Clear(); Console.WriteLine("Game Over!"); if (snake.score > highscore) { highscore = snake.score; Console.WriteLine("New Highscore!"); using (StreamWriter sw = new StreamWriter("Highscore.TXT")) sw.WriteLine(highscore); } Console.WriteLine("\nScore: " + snake.score); Console.WriteLine("Highscore: " + highscore); Console.WriteLine("\nPress Enter to play again"); } while (Console.ReadKey().Key == ConsoleKey.Enter); } if (gameChoice == ConsoleKey.D2) { do { Console.Clear(); Doom doom = new Doom(); doom.Start(); do { doom.Update(); //System.Threading.Thread.Sleep(1000 / 60); } while (true); } while (Console.ReadKey().Key == ConsoleKey.Enter); } } while (gameChoice != ConsoleKey.Escape); }