Example #1
0
 /// <summary>
 /// The GameTimerEventHandler method is called to update the game.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GameTimerEventHandler(object sender, object e)
 {
     if (IsGameOver)
     {
         // Game over.
         if (_gameTimer.IsEnabled)
         {
             _gameTimer.Stop();  // Stop the game timer.
             RestartGame();      // Restart the game.
         }
     }
     else
     {
         // Game running.
         TheSnake.UpdateSnakeStatus(TheCherry);
     }
 }
Example #2
0
 /// <summary>
 /// The ProcessKeyboardEvent method is called to process a keyboard event.
 /// </summary>
 /// <param name="direction"></param>
 public void ProcessKeyboardEvent(Direction direction)
 {
     TheSnake.SetSnakeDirection(direction);
 }
Example #3
0
 public static void InitGame()
 {
     GameBoard.BuildBoard();
     TheSnake.MoveSnake();
 }