/// <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() { // TODO: Add your initialization logic here oldKeyboard = new KeyboardState(); currentKeyboard = new KeyboardState(); //Ball takes a Point object in its constructor. //we must therefore instantiate Point at the same time as the new Ball() // ( new Point( x, y) ) oBall = new Ball(new Point(graphics.GraphicsDevice.Viewport.Width/2, graphics.GraphicsDevice.Viewport.Height/2)); oPaddleOne = new Paddle(new Vector2(0, graphics.GraphicsDevice.Viewport.Height/2)); //oPaddleTwo = new Paddle(new Vector2((graphics.GraphicsDevice.Viewport.Bounds.Right - tPaddleOne.Width), graphics.GraphicsDevice.Viewport.Height/2)); base.Initialize(); //Any objects referencing 'previous' objects, must be instantiated after Initialize(); rPaddleOne = new Rectangle((int)oPaddleOne.vPosition.X, (int)oPaddleOne.vPosition.Y, tPaddleOne.Width, tPaddleOne.Height); //rPaddleTwo = new Rectangle((int)oPaddleTwo.vPosition.X, (int)oPaddleTwo.vPosition.Y, // tPaddleTwo.Width, tPaddleTwo.Height); rBall = new Rectangle((int)oBall.pPosition.X, (int)oBall.pPosition.Y, tEarth.Width, tEarth.Height); }
void Reset() { oBall = new Ball(new Point(400, 300)); oPaddleOne = new Paddle(new Vector2(0, 300)); oPaddleTwo = new Paddle(new Vector2((graphics.GraphicsDevice.Viewport.Bounds.Right - tPaddleOne.Width), 300)); rPaddleOne = new Rectangle((int)oPaddleOne.vPosition.X, (int)oPaddleOne.vPosition.Y, tPaddleOne.Width, tPaddleOne.Height); rPaddleTwo = new Rectangle((int)oPaddleTwo.vPosition.X, (int)oPaddleTwo.vPosition.Y, tPaddleTwo.Width, tPaddleTwo.Height); rBall = new Rectangle((int)oBall.pPosition.X, (int)oBall.pPosition.Y, tEarth.Width, tEarth.Height); }
/// <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() { // TODO: Add your initialization logic here oldKeyboard = new KeyboardState(); currentKeyboard = new KeyboardState(); //Ball takes a Point object in its constructor. //we must therefore instantiate Point at the same time as the new Ball() // ( new Point( x, y) ) oBall = new Ball(new Point(400, 300)); base.Initialize(); }