Пример #1
0
        public void checkCollosions()
        {
            if (ball.X <= leftPaddle.X + leftPaddle.texture.Width + 0.01)
            {
                if (!leftPaddle.checkCollosion(ball))
                {
                    this.Exit();
                }
                else
                {
                    beep.Play();
                    ball.goesLeft = false;
                }
            }
            else if (ball.X >= rightPaddle.X - rightPaddle.texture.Width / 2)
            {
                if (!rightPaddle.checkCollosion(ball))
                {
                    this.Exit();
                }
                else
                {
                    beep.Play();
                    ball.goesLeft = true;
                }
            }
            else if (ball.Y - ball.texture.Height <= upFrame.Y)
            {
                upFrame.hitBall(ball, true);
                ball.goesDown = true;
                beep.Play();
            }

            else if (ball.Y + ball.texture.Height / 2 >= downFrame.Y)
            {
                downFrame.hitBall(ball, true);
                ball.goesDown = false;
                beep.Play();
            }
        }