Beispiel #1
0
        /// <summary>
        /// If the position of the head of the snake is equals to the position of the food, it adds a new piece to the body of the snake and adds a new food on some random place
        /// </summary>
        private bool CheckIfFoodWasEatenByTheSnake()
        {
            if (_snake.Head.Equals(_food))
            {
                SoundsEngine.PlayIncreaseScoreSound();

                AddNewSnakePieceToBodyAfterEat();
                IncreaseScore();
                AddNewFoodInARandomPlace();

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        private void DisplayGameOverMessageAndStopGame()
        {
            gameTimer.Stop();
            SoundsEngine.PlayGameOverSound();

            const string            message = "Do you want to start again?";
            const string            title   = "Game Over!!!";
            const MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult            result  = MessageBox.Show(message, title, buttons);

            if (result == DialogResult.Yes)
            {
                StartNewGame();
            }
            else
            {
                Close();
            }
        }