/// <summary> /// Load your graphics content /// </summary> protected override void LoadContent() { //Creates a new SpriteBatch, which is used to draw textures. spriteBatch = new SpriteBatch(graphics.GraphicsDevice); // Load the SoundEffect resource explosion = Content.Load<SoundEffect>("explosion"); missilelaunch = Content.Load<SoundEffect>("missilelaunch"); //Initialize game background. backgroundTexture = Content.Load<Texture2D>("background"); //Initialize the position and texture of the player's cannon. cannon = new GameObject(Content.Load<Texture2D>("cannon")); cannon.position = new Vector2(120, graphics.GraphicsDevice.Viewport.Height - 80); //Initialize an array of new cannonball GameObjects that can be fired by the player. cannonBalls = new GameObject[maxCannonBalls]; for (int i = 0; i < maxCannonBalls; i++) { //Load player's cannonball sprite. cannonBalls[i] = new GameObject(Content.Load<Texture2D>("cannonball")); } //Initialize enemies. enemies = new GameObject[maxEnemies]; for (int i = 0; i < maxEnemies; i++) { //Load enemy sprite. enemies[i] = new GameObject( Content.Load<Texture2D>("enemy")); } //Load the font sprite that will be used for Score keeping. font = Content.Load<SpriteFont>("Arial"); //Create a Rectangle that represents the full drawable area of the game screen. viewportRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); base.LoadContent(); }
/// <summary> /// Load your graphics content /// </summary> protected override void LoadContent() { //Creates a new SpriteBatch, which is used to draw textures. spriteBatch = new SpriteBatch(graphics.GraphicsDevice); // Load the SoundEffect resource bowshot = Content.Load<SoundEffect>("bowshot"); bgmusicrough = Content.Load<Song>("bgmusicrough"); gameover = Content.Load<SoundEffect>("gameover"); hit1 = Content.Load<SoundEffect>("hit1"); hit2 = Content.Load<SoundEffect>("hit2"); birdhit = Content.Load<SoundEffect>("birdhit"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(bgmusicrough); //Initialize game background. backgroundTexture = Content.Load<Texture2D>("background"); state1 = Content.Load<Texture2D>("state1"); state2 = Content.Load<Texture2D>("state2"); state3 = Content.Load<Texture2D>("state3"); state4 = Content.Load<Texture2D>("state4"); arrow = Content.Load<Texture2D>("arrow"); owl1 = Content.Load<Texture2D>("owl1"); owl2 = Content.Load<Texture2D>("owl2"); owl3 = Content.Load<Texture2D>("owl3"); mouseBody = Content.Load<Texture2D>("mousebody"); mouseheadnshoulders = Content.Load<Texture2D>("mouseheadnshoulders"); //Initialize the position and texture of the player's cannon. cannon = new GameObject(mouseheadnshoulders); cannon.position = new Vector2(668, 253); //Initialize an array of new cannonball GameObjects that can be fired by the player. cannonBalls = new GameObject[maxCannonBalls]; for (int i = 0; i < maxCannonBalls; i++) { //Load player's cannonball sprite. cannonBalls[i] = new GameObject(arrow); } //Initialize enemies. enemies = new GameObject[maxEnemies]; for (int i = 0; i < maxEnemies; i++) { //Load enemy sprite. if (i % 3 == 0) { enemies[i] = new GameObject( owl1); } if (i % 3 == 1) { enemies[i] = new GameObject( owl2); } if (i % 3 == 2) { enemies[i] = new GameObject( owl3); } } //Load the font sprite that will be used for Score keeping. font = Content.Load<SpriteFont>("Arial"); //Create a Rectangle that represents the full drawable area of the game screen. viewportRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); base.LoadContent(); }