Beispiel #1
0
        public void updatepaddle(Ball ball,Paddle P)
        {
            counter++;
            AIPaddle = P;
            Vector2 PaddleCenter = new Vector2(AIPaddle.Position.X, AIPaddle.Position.Y + (AIPaddle.Height) / 2);
            if (counter != Difficulty)
            {

                if (ball.Location.Y > (PaddleCenter.Y) && ball.Motion.X < 0)
                {
                    AIPaddle.computerinput(10);
                }
                else if (ball.Location.Y < (PaddleCenter.Y) && ball.Motion.X < 0)
                {
                    AIPaddle.computerinput(-10);
                }

                else if (ball.Motion.X < 0 && PaddleCenter.Y < 250)
                {
                    AIPaddle.computerinput(10);
                }
                else if (ball.Motion.X < 0 && PaddleCenter.Y > 250)
                {
                    AIPaddle.computerinput(-10);
                }
            }
            else { counter = 0; }
        }