Advertisement
Guest User

Changes (Background)

a guest
Feb 19th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.48 KB | None | 0 0
  1. Added Fields:
  2.  
  3. private Texture2D background;
  4. Changes to LoadContent:
  5. protected override void LoadContent()
  6.         {
  7.             // Create a new SpriteBatch, which can be used to draw textures.
  8.             spriteBatch = new SpriteBatch(GraphicsDevice);
  9.  
  10.             texture = this.Content.Load<Texture2D>("Bee");
  11.  
  12.             text1 = Content.Load<SpriteFont>("text");
  13.  
  14.             background = Content.Load<Texture2D>("Background");
  15.  
  16.  
  17.             // Sound
  18.             backgroundSound = Content.Load<Song>("Happy_Dreams.Background");
  19.             MediaPlayer.Play(backgroundSound);
  20.             MediaPlayer.Volume -= 0.5f;
  21.             MediaPlayer.IsRepeating = true;
  22.  
  23.             // TODO: use this.Content to load your game content here
  24.             gameObjects.Add(new Drone(new Vector2(0, 0)));
  25.             //gameObjects.Add(new Mine(new Vector2(200, 100));
  26.  
  27.             foreach (GameObject gameObject in gameObjects)
  28.             {
  29.                 gameObject.LoadContent(Content);
  30.             }
  31.         }
  32. Changes to Draw:
  33. protected override void Draw(GameTime gameTime)
  34.         {
  35.             GraphicsDevice.Clear(Color.CornflowerBlue);
  36.  
  37.             // TODO: Add your drawing code here
  38.             spriteBatch.Begin();
  39.             spriteBatch.Draw(background, position, origin: new Vector2(0, 0));
  40.             spriteBatch.End();
  41.  
  42.             spriteBatch.Begin();
  43.             spriteBatch.Draw(texture, position, origin: new Vector2(64, 64));
  44.  
  45.          
  46.  
  47.  
  48.             foreach (GameObject gameObject in gameObjects)
  49.             {
  50.                 gameObject.Draw(spriteBatch);
  51.             }
  52.  
  53.             spriteBatch.DrawString(text1, nek.nektarInfo,
  54.                                           new Vector2(50, graphics.GraphicsDevice.Viewport.Height / 2),
  55.                                           Color.White,
  56.                                           0,
  57.                                           Vector2.Zero,
  58.                                           1,
  59.                                           SpriteEffects.None,
  60.                                           1f);
  61.  
  62.  
  63.             spriteBatch.DrawString(text1, nek.waitingBees,
  64.                                         new Vector2(100, graphics.GraphicsDevice.Viewport.Height / 2 + 80),
  65.                                         Color.White,
  66.                                         0,
  67.                                         Vector2.Zero,
  68.                                         1,
  69.                                         SpriteEffects.None,
  70.                                         1f);
  71.  
  72.             spriteBatch.DrawString(text1, nek.enteringBees,
  73.                                         new Vector2(100, graphics.GraphicsDevice.Viewport.Height / 2 + 110),
  74.                                         Color.White,
  75.                                         0,
  76.                                         Vector2.Zero,
  77.                                         1,
  78.                                         SpriteEffects.None,
  79.                                         1f);
  80.  
  81.             spriteBatch.DrawString(text1, nek.leavingBees,
  82.                                         new Vector2(100, graphics.GraphicsDevice.Viewport.Height / 2 + 140),
  83.                                         Color.White,
  84.                                         0,
  85.                                         Vector2.Zero,
  86.                                         1,
  87.                                         SpriteEffects.None,
  88.                                         1f);
  89.  
  90.             // Mined nektar
  91.             spriteBatch.DrawString(text1, nek.minedNektar,
  92.                                     new Vector2(100, graphics.GraphicsDevice.Viewport.Height / 2 + 170),
  93.                                     Color.White,
  94.                                     0,
  95.                                     Vector2.Zero,
  96.                                     1,
  97.                                     SpriteEffects.None,
  98.                                     1f);
  99.  
  100.             // Remaining nektar
  101.             spriteBatch.DrawString(text1, nek.remainingNektar,
  102.                                     new Vector2(100, graphics.GraphicsDevice.Viewport.Height / 2 + 200),
  103.                                     Color.White,
  104.                                     0,
  105.                                     Vector2.Zero,
  106.                                     1,
  107.                                     SpriteEffects.None,
  108.                                     1f);
  109.             spriteBatch.End();
  110.  
  111.             base.Draw(gameTime);
  112.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement