예제 #1
0
        //*********************************************************************************************************************************************
        //
        // Method Name: CheckBallCollisionOnBottomBorder
        //
        // Description:
        //  Check if the ball hits the bottom border and decrement the number of lives the player has left. If lives goes below the threshold for game
        //  over, the game reverts back to the start screen. Otherwise a new match begins.
        //
        // Arguments:
        //  theBreakoutGame - The game object that tracks various game elements.
        //
        // Return:
        //  N/A
        //
        //*********************************************************************************************************************************************
        protected override void CheckBallCollisionOnBottomBorder(BreakoutGame theBreakoutGame)
        {
            if (mHitBox.Y > BreakoutConstants.SCREEN_PLAY_AREA_HEIGHT)
            {
                theBreakoutGame.NumberOfLives = theBreakoutGame.NumberOfLives - BreakoutConstants.LIFE_LOST;

                // Check if the number of lives have been used up and end the game if so.
                if (theBreakoutGame.NumberOfLives < 0)
                {
                    theBreakoutGame.NumberOfLives = BreakoutConstants.INITIAL_LIVES_REMAINING;
                    theBreakoutGame.PopState();
                }
                // The player still have spare lives to play so a new match is started.
                else
                {
                    NewMatch();
                    theBreakoutGame.Paddle.NewMatch();
                }
            }
        }