Advertisement
rohits134

AIBat.cs

Jul 5th, 2012
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. namespace Pong_Clone
  2.  {
  3.      using System;
  4.      using Microsoft.Xna.Framework;
  5.      using Microsoft.Xna.Framework.Content;
  6.  
  7.      public class AIBat : Bat
  8.      {
  9.          public AIBat(ContentManager content, Vector2 screenSize, bool side)
  10.              : base(content, screenSize, side)
  11.          {
  12.          }
  13.  
  14.          public override void UpdatePosition(Ball ball)
  15.          {
  16.              if (ball.GetDirection() > 1.5 * Math.PI || ball.GetDirection() < 0.5 * Math.PI)
  17.              {
  18.                  if (ball.GetPosition().Y - 5 > GetPosition().Y + GetSize().Height / 2)
  19.                  {
  20.                      MoveDown();
  21.                  }
  22.                  else if (ball.GetPosition().Y == GetPosition().Y + GetSize().Height / 2)
  23.                  {
  24.                  }
  25.                  else if (ball.GetPosition().Y + 5 < GetPosition().Y + GetSize().Height / 2)
  26.                  {
  27.                      MoveUp();
  28.                  }
  29.              }
  30.              base.UpdatePosition(ball);
  31.          }
  32.      }
  33.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement