コード例 #1
0
ファイル: Game1.cs プロジェクト: jamesferry84/pong
 /// <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
ファイル: Game1.cs プロジェクト: jamesferry84/pong
 private bool Collision(Paddle paddle, Ball ball)
 {
     if (paddle.Rect.Intersects(ball.Rect))
         return true;
     return false;
 }