title: only one tile drawn in map xna c#
body: <p>I am having this problem where the tiles will only draw one specific texture. I have been looking at tile engines for the past few days and decided to have a go at my own one for educational purposes. I have managed to get only one tile on the screen and it draws that tile in the map. in the map it treats all of the tiles as the same texture, whereas I want to be able to determine what tile goes where. For example, 1 = grass, 2 = sky, 3 = dirt etc. I have been following tutorials here and there and searching online to try and find this problem but to no avail. 
  In the LoadContent of the the TileMap class the Console.WriteLine states there are 3 textures loaded into the list.
  I was under the impression that the draw method in the tileMap would set the index to the tile ID corresponding to a tile texture and then that specific tile would be drawn on the map in game. for example, index 1 would equal the first texture in the lost, index 2 would equal the second texture and so on. 
  Is this a correct assumption or am I way off? </p>
  
  <p>Also, can you give me any help/pointers on ways to fix this issue of only one texture showing on the screen.</p>
  
  <p>Thank you in advance.</p>
  
  <p><strong>Tile Map</strong>   </p>
  
  <pre><code> class TileMap
      {
          private MapCell[,] mapCell;
          public const int TILE_WIDTH = 64;
          public const int TILE_HEIGHT = 64;
  
      private List&lt;Texture2D&gt; tileList = new List&lt;Texture2D&gt;();
  
      public TileMap(int[,] exisitingMap)
      {
          //initialise this to a new multidimensional array;
          mapCell = new MapCell[exisitingMap.GetLength(0), exisitingMap.GetLength(1)];
          // x always starts on one 
          for (int x = 0; x &lt; mapCell.GetLength(1); x++)
          {
              for (int y = 0; y &lt; mapCell.GetLength(0); y++)
              {
                  mapCell[y, x] = new MapCell(exisitingMap[y, x]);
              }
          }       
       }
  
      public void loadTextureFiles(ContentManager content, params string[] fileNames)
      {
          Texture2D tileTexture;
          foreach (string fileName in fileNames)
          {
              tileTexture = content.Load&lt;Texture2D&gt;(fileName);
              tileList.Add(tileTexture);
              Console.WriteLine(tileList.Count + " Tile texture count ");
          }
      }
  
      public void Draw(SpriteBatch spriteBatch)
      {
  
          for (int x = 0; x &lt; mapCell.GetLength(1); x++)
          {
              for (int y = 0; y &lt; mapCell.GetLength(0); y++)
              {
                  // setting the index to the tile ID
                  int index = mapCell[y,x].TileID;
                  Texture2D texture = tileList[index];
  
                  spriteBatch.Draw(texture, new Rectangle( x * TILE_WIDTH, y * TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT), Color.White);
  
              }
          }   
      }
  }
  </code></pre>
  
  <p><strong>Map Cell</strong></p>
  
  <pre><code>class MapCell
  {
      public int TileID { get; set; }
  
      public MapCell(int tileID) 
      {
          tileID = TileID;
      }
  }
  </code></pre>
  
  <p><strong>Game1</strong></p>
  
  <pre><code>TileMap tileMap = new TileMap(new int[,]
      {
          { 0,0,0,0,0,0,0 },
          { 1,1,1,1,1,1,1 },
          { 0,1,1,2,1,1,1 },
          { 0,2,1,3,1,3,0 },
          { 0,3,0,3,0,0,0 },
          { 0,0,0,2,0,0,0 },
          { 0,0,0,1,0,1,0 },
      });
  
   protected override void LoadContent()
      {
          new SpriteBatch(GraphicsDevice);
          tileMap.loadTextureFiles(Content, "Tiles/Tile1", "Tiles/sky", "Tiles/dirt" );  
      }
  
  protected override void Draw(GameTime gameTime)
      {
          spriteBatch.Begin();
          tileMap.Draw(spriteBatch);
          base.Draw(gameTime);
  
          spriteBatch.End();
      }
  </code></pre>