Beispiel #1
0
        public static void Menu()
        {
            var check = true;

            while (check)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("1 - New game!");
                Console.WriteLine("2 - Best results!");
                Console.WriteLine("3 - Exit game!");
                var point = Console.ReadKey();
                switch (point.Key)
                {
                case ConsoleKey.D1:
                    Console.Clear();
                    var game = new Game();
                    game.NewGame();
                    break;

                case ConsoleKey.D2:
                    Console.Clear();
                    BestResult.ViewResults(10);
                    break;

                case ConsoleKey.D3:
                    check = false;
                    return;

                default:
                    Console.Clear();
                    break;
                }
            }
        }
Beispiel #2
0
 private void GameOver()
 {
     if (_lives > 0)
     {
         Console.SetCursorPosition((Console.WindowWidth - 20) / 2, Console.WindowHeight / 2);
         Console.WriteLine("You lost. Press to continue");
         Console.ReadKey();
         _lives--;
         Console.Clear();
         _snake.ClearSnake();
         NewGame();
     }
     else
     {
         _play = false;
         Console.ForegroundColor = ConsoleColor.Red;
         var str = "GAME OVER";
         Console.SetCursorPosition((Console.WindowWidth - str.Length) / 2, Console.WindowHeight / 2);
         Console.WriteLine(str);
         Console.ResetColor();
         BestResult.WriteResult(_score);
     }
 }