Beispiel #1
0
 private void RealThink(Ball ball)
 {
     if (ball.Midpoint().Y > Midpoint().Y)
     {
         if (Velocity.Y < _yVelocity)
         {
             Velocity.Y += 0.05f;
             if (Velocity.Y > _yVelocity)
             {
                 Velocity.Y = _yVelocity;
             }
         }
     }
     else if (ball.Midpoint().Y < Midpoint().Y)
     {
         if (Velocity.Y > -_yVelocity)
         {
             Velocity.Y -= 0.05f;
             if (Velocity.Y < -_yVelocity)
             {
                 Velocity.Y = -_yVelocity;
             }
         }
     }
     else if (ball.Midpoint().Y == Midpoint().Y)
     {
         Velocity.Y = 0.0f;
     }
 }
Beispiel #2
0
        private Vector2 CollisionPoint(bool playerCollision, Ball ball)
        {
            float x, y = ball.Midpoint().Y;

            if (playerCollision)
            {
                x = _player.Position.X + _player.Width;
            }
            else
            {
                x = _ai.Position.X;
            }

            return new Vector2(x, y);
        }