protected override void LoadContent() { // Create new SpriteBatch for texture drawing. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: this.Content for loading game content gameContent = new GameContent(Content); screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; if (screenWidth >= 502) { screenWidth = 502; } if (screenHeight >= 700) { screenHeight = 700; } graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.ApplyChanges(); // Game Objects int paddleX = (screenWidth - gameContent.ImgPaddle.Width) / 2; // center paddle int paddleY = screenHeight - 100; // paddle 100 pixels from bottom paddle = new Paddle(paddleX, paddleY, screenWidth, spriteBatch, gameContent); // create paddle wall = new Wall(1, 50, spriteBatch, gameContent); // create wall gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent); // create game border ball = new Ball(screenWidth, screenHeight, spriteBatch, gameContent); staticBall = new Ball(screenWidth, screenHeight, spriteBatch, gameContent) // for indicating 'balls left' { X = 25, Y = 25, Visible = true, UseRotation = false }; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here gameContent = new GameContent(Content); screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; //set game to 502x700 or screen max if smaller if (screenWidth >= 502) { screenWidth = 502; } if (screenHeight >= 700) { screenHeight = 700; } graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.ApplyChanges(); //create game objects int paddleX = (screenWidth - gameContent.imgPaddle.Width) / 2; //we'll center the paddle on the screen to start int paddleY = screenHeight - 100; //paddle will be 100 pixels from the bottom of the screen paddle = new Paddle(paddleX, paddleY, screenWidth, spriteBatch, gameContent); // create the game paddle wall = new Wall(1, 50, spriteBatch, gameContent); gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent); ball = new Ball(screenWidth, screenHeight, spriteBatch, gameContent); staticBall = new Ball(screenWidth, screenHeight, spriteBatch, gameContent); staticBall.X = 25; staticBall.Y = 25; staticBall.Visible = true; staticBall.UseRotation = false; }