示例#1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     playerPaddle = new Paddle(Content, "paddle1", new Vector2(0,0),true);
     computerPaddle = new Paddle(Content, "paddle1", new Vector2((GraphicsDevice.Viewport.Width - TEXTUREWIDTH), 0),false);
     ball = new Ball(Content, "ball", new Vector2((GraphicsDevice.Viewport.Width / 2),(GraphicsDevice.Viewport.Height / 2)));
     base.Initialize();
 }
示例#2
0
 private bool Collision(Paddle paddle, Ball ball)
 {
     if (paddle.Rect.Intersects(ball.Rect))
         return true;
     return false;
 }