Exemplo n.º 1
0
        public void Update(Ball b, Paddle p)
        {
            float target = 0f;
              if (b.Velocity [1] > 0)
            target = b.Position [0];

              float distance_to_target = Math.Abs(target - p.Position [0]);
              if (distance_to_target < p.Speed) {
            distance_to_target = distance_to_target / 10f;
            if (distance_to_target < 1f)
              distance_to_target = 0f;
              }

              if (target > p.Position[0])
            p.MoveRight(distance_to_target);
              if (target < p.Position[0])
            p.MoveLeft(distance_to_target);
        }
Exemplo n.º 2
0
        public void Update(Ball b, Paddle p)
        {
            var target = b.Position [0];

              float distance_to_target = Math.Abs(target - p.Position [0]);
              if (distance_to_target < 1f)
            return;

              /* Don't jerk */
              if ((distance_to_target > 2f) && (distance_to_target < 2.5f)) {
            distance_to_target = 0.3f;
              }

              if (target > p.Position[0])
            p.MoveRight(distance_to_target);

              if (target < p.Position[0])
            p.MoveLeft(distance_to_target);
        }