Esempio n. 1
0
        void CheckCollisions(GameTime gameTime)
        {
            /*            if (ball.CheckCollisonWithPaddle(leftPaddle.body))
             *          {
             *              leftPaddle.Hit();
             *          }
             *          leftPaddle.CheckIfHitted(gameTime);
             *
             *          if (ball.CheckCollisonWithPaddle(rightPaddle.body))
             *          {
             *              rightPaddle.Hit();
             *          }*/
            if (leftPaddle.CheckCollisionWithBall(ball))
            {
                leftPaddle.Hit();
            }
            else
            if (rightPaddle.CheckCollisionWithBall(ball))
            {
                rightPaddle.Hit();
            }
            else
            {
                if (ball.CheckCollisionWithWall(0, GraphicsDevice.Viewport.Width) == 'l')
                {
                    RightScore.AddPoint();
                    ball.DestroyBall(gameTime, GraphicsDevice.Viewport.Width);

                    play = false;
                }
                else if (ball.CheckCollisionWithWall(0, GraphicsDevice.Viewport.Width) == 'r')
                {
                    LeftScore.AddPoint();
                    ball.DestroyBall(gameTime, GraphicsDevice.Viewport.Width);

                    play = false;
                }
            }
            rightPaddle.CheckIfHitted(gameTime);



            ball.BounceFromWall(GraphicsDevice.Viewport.Height);
        }