public void RunApplication() { bool isRunning = true; HighScore.SeedScores(); while (isRunning) { Console.WriteLine("Welcome to the Insatiably Hungry Snake Game! \n" + $"1. Play on board size {currentOptions.BoardSize} at difficulty level {currentOptions.Difficulty}. \n" + "2. Choose Board Size \n" + "3. Set Game Difficulty \n" + "4. Show High Scores \n" + "5. Rules \n" + "6. Game Options \n" + "7. Authors"); string userInput = Console.ReadLine(); switch (userInput) { case "1": currentGame.StartGame(currentOptions); break; case "2": Console.WriteLine("1. Small \n" + "2. Medium \n" + "3. Large"); string userChoice = Console.ReadLine(); switch (userChoice) { case "1": currentOptions.BoardSize = GameBoardSize.small; Console.Clear(); break; case "2": currentOptions.BoardSize = GameBoardSize.medium; Console.Clear(); break; case "3": currentOptions.BoardSize = GameBoardSize.large; Console.Clear(); break; default: break; } ; break; case "3": Console.WriteLine("1. Easy \n" + "2. Medium \n" + "3. Hard"); string userOption = Console.ReadLine(); switch (userOption) { case "1": currentOptions.Difficulty = GameDifficulty.easy; Console.Clear(); break; case "2": currentOptions.Difficulty = GameDifficulty.medium; Console.Clear(); break; case "3": currentOptions.Difficulty = GameDifficulty.hard; Console.Clear(); break; default: break; } Console.Clear(); break; case "4": Console.WriteLine("Top 5 Scores of All Time: \n" + $"1. {userName} scored {userHighScore} \n" + $"2. {userName} scored {userHighScore} \n" + $"3. {userName} scored {userHighScore} \n" + $"4. {userName} scored {userHighScore} \n" + $"5. {userName} scored {userHighScore}"); Console.Clear(); break; case "5": Console.WriteLine("\n" + "RULES: \n" + "\n" + "You will play the intolerably-hungry Blake the Snake. \n" + "Consuming food will help Blake grow; it will also increase your score. \n" + "Use your keyboard arrow keys to move Blake up, down, left, and right. \n" + "\n" + "SCORING: \n" + "\n" + "Some food is more common than others, so its value differs: \n" + "@ Apples are very common, so they are worth 10 points.\n" + "* Cotton candy is less common, with a worth of 15 points.\n" + "¥ People are rare, with a value of 25 points.\n" + "~ Bacon: almost as good as chocolate. 50 points.\n" + "\n" + "GAME ENDING: \n" + "\n" + "If the snake hits the side of the board, the game ends. \n" + "And if Blake takes a nibble of himself (runs into himself), the game also ends... for so many reasons.\n"); Console.WriteLine("Press any key to return to the main menu........"); Console.ReadKey(); Console.Clear(); break; case "6": //game options Console.Clear(); break; case "7": Console.WriteLine("\n" + "AUTHORS: \n" + "\n" + "Jeff Deacon & Rochelle Deulley \n" + "\n" + "Contact for more world-changing applications... including a device that eliminates garbage with zero net emissions. \n" + "Patent pending.\n" + "\n"); Console.WriteLine("Press any key to return to the main menu........"); Console.ReadKey(); Console.Clear(); break; } } }
//We may want to investigate setting the window size. //DrawBoard is the turn mechanism for the game. public void DrawBoard(GameOptions gameOptions) { bool dead = false; while (dead == false) { Console.WriteLine(); Console.WriteLine(); Console.WriteLine($" Score: {score} High Score: xxxxx"); DrawBoardTop(gameOptions.BoardWidth); DrawBoardLine(gameOptions.BoardWidth, gameOptions.BoardHeight); DrawBoardBottom(gameOptions.BoardWidth); if (Console.KeyAvailable) //This is true if a key has been pressed. This prevents the game for waiting for a key stroke. { var changeDirection = Console.ReadKey(true).Key; switch (changeDirection) { case ConsoleKey.LeftArrow: snakeRepo.GetSnake(0).Direction = MoveDirection.Left; break; case ConsoleKey.UpArrow: snakeRepo.GetSnake(0).Direction = MoveDirection.Up; break; case ConsoleKey.RightArrow: snakeRepo.GetSnake(0).Direction = MoveDirection.Right; break; case ConsoleKey.DownArrow: snakeRepo.GetSnake(0).Direction = MoveDirection.Down; break; } } snakeRepo.AddSnake(snakeRepo.CreateNewHead(snakeRepo.GetSnake(0))); //Creates a new snake object and ADDs it at index 0 to the _gameSnake List, so its the first object in the list. snakeRepo.RemoveSnake(); //Removes the highest index snake object from the _gameSnake list dead = CheckCollision(snakeRepo.GetSnake(0), gameOptions); // Checks for snake collision and death //Remove Fruit, add a new random fruit, and increase score by fruit value. bool EatFruit = CheckForFruit(snakeRepo.GetSnake(0), gameOptions); if (EatFruit) { ItemLocations itemToRemove = GetItem(snakeRepo.GetSnake(0).XAxis, snakeRepo.GetSnake(0).YAxis); gameItems.Remove(itemToRemove); while (gameItems.Count < 3) { gameItems.Add(AddGameItems(gameOptions)); RemoveNullItems(); } snakeRepo.AddSnake(snakeRepo.CreateNewHead(snakeRepo.GetSnake(0))); } Thread.Sleep(gameSpeed); // <- Needs to be set with the difficulty paramater ################################# Console.Clear(); } Console.WriteLine("You DEAD!"); // Needs to implement Rochelles menu and replace lines 86 & 87 Console.WriteLine("Congratulations! You've achieved a high score. Please enter your name:"); var UserNameInput = Console.ReadLine(); string userScore = HighScore.ShowPlayerScore(UserNameInput, score); Console.WriteLine("??"); Console.WriteLine($"{userScore}"); Console.ReadLine(); }