示例#1
0
文件: AIBat.cs 项目: rohit12/Pong
 public override void UpdatePosition(Ball ball)
 {
     if (ball.GetDirection() > 1.5 * Math.PI || ball.GetDirection() < 0.5 * Math.PI)
      {
          if (ball.GetPosition().Y - 5 > GetPosition().Y + GetSize().Height / 2)
          {
              MoveDown();
          }
          else if (ball.GetPosition().Y == GetPosition().Y + GetSize().Height / 2)
          {
          }
          else if (ball.GetPosition().Y + 5 < GetPosition().Y + GetSize().Height / 2)
          {
              MoveUp();
          }
      }
      base.UpdatePosition(ball);
 }
示例#2
0
文件: Game1.cs 项目: rohit12/Pong
 protected override void Initialize()
 {
     screenHeight = 600;
     screenWidth = 800;
     menu = new Menu();
     gamestate = GameStates.Menu;
     resetTimer = 0;
     resetTimerInUse = true;
     lastScored = false;
     graphics.PreferredBackBufferWidth = screenWidth;
     graphics.PreferredBackBufferHeight = screenHeight;
     graphics.IsFullScreen = false;
     graphics.ApplyChanges();
     ball = new Ball(Content, new Vector2(screenWidth, screenHeight));
     SetUpMulti();
     input = new Input();
     base.Initialize();
 }