title: XNA objects not drawing
body: <p>So I have a problem that I cant figure out, and that is drawing objects into my main Game1 class from a class of drawablegamecomponent. </p>
  
  <p>I'v been playing around with it for a bit and looking at other examples, but can't figure out the issue. There isn't much code as it is, so I'll just post the two classes I have, the main class Game1 and the class I want to draw, Balloon.</p>
  
  <p>The error is in the draw method I get this...</p>
  
  <pre><code>An unhandled exception of type 'System.NullReferenceException' occurred in Burst.exe
  
  Additional information: Object reference not set to an instance of an object.
  </code></pre>
  
  <p>Main Class.</p>
  
  <pre><code>   using System;
  using System.Collections.Generic;
  using System.Linq;
  using Microsoft.Xna.Framework;
  using Microsoft.Xna.Framework.Audio;
  using Microsoft.Xna.Framework.Content;
  using Microsoft.Xna.Framework.GamerServices;
  using Microsoft.Xna.Framework.Graphics;
  using Microsoft.Xna.Framework.Input;
  using Microsoft.Xna.Framework.Media;
  
  namespace Burst
  {
      /// &lt;summary&gt;
      /// This is the main type for your game
      /// &lt;/summary&gt;
      public class Game1 : Microsoft.Xna.Framework.Game
      {
          GraphicsDeviceManager graphics;
          SpriteBatch spriteBatch;
          Rectangle bounds;
          Balloon ball;
          Diamond dia;
  
  
  
  
          public Game1()
          {
              graphics = new GraphicsDeviceManager(this);
              graphics.PreferredBackBufferWidth = 1152;
              graphics.PreferredBackBufferHeight = 648;
              Content.RootDirectory = "Content";
  
  
              bounds = new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
  
              ball = new Balloon(bounds, 1, this, spriteBatch);
              dia = new Diamond(bounds, new Vector2(200, 200), this, spriteBatch);
  
          }
  
  
  
  
          /// &lt;summary&gt;
          /// 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.
          /// &lt;/summary&gt;
          protected override void Initialize()
          {
              // TODO: Add your initialization logic here
  
  
              base.Initialize();
          }
  
          /// &lt;summary&gt;
          /// LoadContent will be called once per game and is the place to load
          /// all of your content.
          /// &lt;/summary&gt;
          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
          }
  
          /// &lt;summary&gt;
          /// UnloadContent will be called once per game and is the place to unload
          /// all content.
          /// &lt;/summary&gt;
          protected override void UnloadContent()
          {
              // TODO: Unload any non ContentManager content here
          }
  
          /// &lt;summary&gt;
          /// Allows the game to run logic such as updating the world,
          /// checking for collisions, gathering input, and playing audio.
          /// &lt;/summary&gt;
          /// &lt;param name="gameTime"&gt;Provides a snapshot of timing values.&lt;/param&gt;
          protected override void Update(GameTime gameTime)
          {
              // Allows the game to exit
              if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                  this.Exit();
  
              // TODO: Add your update logic here
  
              ball.Update();
              base.Update(gameTime);
          }
  
          /// &lt;summary&gt;
          /// This is called when the game should draw itself.
          /// &lt;/summary&gt;
          /// &lt;param name="gameTime"&gt;Provides a snapshot of timing values.&lt;/param&gt;
          protected override void Draw(GameTime gameTime)
          {
              GraphicsDevice.Clear(Color.CornflowerBlue);
  
              spriteBatch.Begin();
              // TODO: Add your drawing code here
              ball.Draw(gameTime);
              dia.Draw(gameTime);
              spriteBatch.End();
              base.Draw(gameTime);
          }
      }
  }
  </code></pre>
  
  <p>Balloon Class:</p>
  
  <pre><code> using Microsoft.Xna.Framework;
  using Microsoft.Xna.Framework.Graphics;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace Burst
  {
  
      public class Balloon : Microsoft.Xna.Framework.DrawableGameComponent
      {
  
          Vector2 position;
          Vector2 motion;
          Texture2D texture;
          Rectangle bounds;
          Rectangle screenBounds;
          Game game;
          SpriteBatch spriteBatch;
  
  
          float balloonSpeed = 4;
  
          int colour = 0;
  
  
  
  
          public Balloon(Rectangle screenBounds, int colour, Game game, SpriteBatch spriteBatch) : base (game)
          {
              this.colour = colour;
              this.game = game;
              this.spriteBatch = spriteBatch;
              this.screenBounds = screenBounds;
              this.position = new Vector2(200,200);
  
          }
  
         protected override void LoadContent()
          {
  
              switch (colour)
              {
                  case 1: texture = Game.Content.Load&lt;Texture2D&gt;("Images/BlueBalloon");
                      break;
                  case 2: texture = Game.Content.Load&lt;Texture2D&gt;("Images/GreenBalloon");
                      break;
                  case 3: texture = Game.Content.Load&lt;Texture2D&gt;("Images/RedBalloon");
                      break;
                  case 4: texture = Game.Content.Load&lt;Texture2D&gt;("Images/YellowBalloon");
                      break;
                  case 5: texture = Game.Content.Load&lt;Texture2D&gt;("Images/PurpleBalloon");
                      break;
              }
          }
  
  
          public Rectangle Bounds
          {
              get
              {
                  bounds.X = (int)position.X;
                  bounds.Y = (int)position.Y;
                  return bounds;
              }
          }
  
  
          public void Update()
          {
              position += motion * balloonSpeed;
  
          }
  
          private void CheckWallColision()
          {
              if (position.X &lt; 0)
              {
                  position.X = 0;
                  motion.X *= -1;
              }
  
              if (position.X + texture.Width &gt; screenBounds.Width)
              {
                  position.X = screenBounds.Width - texture.Width;
                  motion.X *= -1;
              }
  
              if (position.Y &lt; 0)
              {
                  position.Y = 0;
                  motion.Y *= -1;
              }
  
              if (position.Y + texture.Height &gt; screenBounds.Height)
              {
  
                  position.Y = screenBounds.Height - texture.Height;
                  motion.Y *= -1;
              }
          }
  
          public void SetStartPosition()
          {
              Random rand = new Random();
  
              motion = new Vector2(rand.Next(2, 6), -rand.Next(2, 6));
              motion.Normalize();
  
              position = new Vector2(200, 300);
  
          }
  
  
          public void Draw()
          {
              spriteBatch.Draw(texture, position, Color.White); 
  
          }
      }
  }
  </code></pre>