title: Drawing the board game Ludo in XNA using 2Darrays
body: <p>I’m a beginner in C# and XNA, and I am currently trying to make the board game LUDO. I have done some java programming before and are common with object oriented programming. So the thing that I am stuck at, at this moment is to draw the sprites of the “board”. </p>
  
  <p>I made all the sprites I am using myself in MS paint, all the different sprites (26 different sprites) have all the same size 45px X 45px. What I was thinking was to make a 2Darray that contains of numbers, these numbers will refer to the specific sprite in a texture array. Example: Here is a link to the type of board I am setting up: <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Klassisk_ludo-spill.JPG/220px-Klassisk_ludo-spill.JPG" rel="nofollow">http://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Klassisk_ludo-spill.JPG/220px-Klassisk_ludo-spill.JPG</a></p>
  
  <p>My 2Darray is setup is as follow: it starts on the top of the board and then goens from left to right. So this is how i made my 2Darray:</p>
  
  <pre><code>//Create the full grid of the board, where the numbers refer to the sprites that is supposed to be
      // placed here. the array starts from the top of the bord from left to right and then goes downwards.
      int[,] myArray = new  int[,] {{3,3,3,3,3,3,4,4,4,0,0,0,0,0,0},
                                    {3,24,25,23,25,3,4,0,0,0,12,13,12,13,0},
                                    {3,22,23,22,23,3,4,0,4,0,10,11,10,11,0},
                                    {3,24,25,23,25,3,4,0,4,0,12,13,12,13,0},
                                    {3,22,23,22,23,3,4,0,4,0,10,11,10,11,0},
                                    {3,3,3,3,3,3,4,0,4,0,0,0,0,0,0},
                                    {4,3,4,4,4,4,6,0,5,4,4,4,4,4,4},
                                    {4,3,3,3,3,3,3,9,1,1,1,1,1,1,4},
                                    {4,4,4,4,4,4,7,2,8,4,4,4,4,1,4},
                                    {2,2,2,2,2,2,4,2,4,1,1,1,1,1,1},
                                    {2,20,21,20,21,2,4,2,4,1,16,17,16,17,1},
                                    {2,18,19,18,19,2,4,2,4,1,14,15,14,15,1},
                                    {2,20,21,20,21,2,4,2,4,1,16,17,16,17,1},
                                    {2,18,19,18,19,2,2,2,4,1,14,15,14,15,1},
                                    {2,2,2,2,2,2,4,4,4,1,1,1,1,1,1}};
  </code></pre>
  
  <p>like i said these numbers are suppose to correspond to a spesific sprite in another texture array. Here is a overview of what number corresponds to what sprite:</p>
  
  <pre><code>textureArray = newTexture2D[26];
  0 = blueblock;
  1 = redblock;
  2 = yellowBlock;
  3 = greenBlock;
  4 = whiteBlock;
  5 = blueredBlock;
  6 = greenblueBlock;
  7 = greenyellowBlock;
  8 = yellowredBlock;
  9 = xcenterBlock;
  10 = BlueBottomLeftBlock;
      11 = BlueBottomRightBlock;
      12 = BlueTopLeftBlock;
      13 = BlueTopRightBlock;
      14 = RedBottomLeftBlock;
      15 = RedBottomRightBlock;
      16 = RedTopLeftBlock;
      17 = RedTopRightBlock;
      18 = YellowBottomLeftBlock;
      19 = YellowBottomRightBlock;
      20 = YellowTopLeftBlock;
      21 = YellowTopRightBlock;
      22 = GreenBottomLeftBlock;
      23 = GreenBottomRightBlock;
      24 = GreenTopLeftBlock;
      25 = GreenTopRightBlock;
  </code></pre>
  
  <p>At the moment i have made a content manager in my background class that looks like this:</p>
  
  <pre><code>// ContentManager that is loadedes textures and position for the objects in to game1
      public void LoadContent(ContentManager content)
      {
          this._BlueBlock = content.Load&lt;Texture2D&gt;("blue-block");
          this._RedBlock = content.Load&lt;Texture2D&gt;("red-block");
          this._YellowBlock = content.Load&lt;Texture2D&gt;("yellow-block");
          this._GreenBlock = content.Load&lt;Texture2D&gt;("green-block");
          this._WhiteBlock = content.Load&lt;Texture2D&gt;("white-block");
          this._BlueRedBlock = content.Load&lt;Texture2D&gt;("blue-red-block");
          this._GreenBlueBlock = content.Load&lt;Texture2D&gt;("green-blue-block");
          this._GreenYellowBlock = content.Load&lt;Texture2D&gt;("green-yellow-block");
          this._YellowRedBlock = content.Load&lt;Texture2D&gt;("yellow-red-block");
          this._XCenterBlock = content.Load&lt;Texture2D&gt;("x-center-block");
          this._BlueBottomLeftBlock = content.Load&lt;Texture2D&gt;("blue-bottomleft-block");
          this._BlueBottomRightBlock = content.Load&lt;Texture2D&gt;("blue-bottomright-block");
          this._BlueTopLeftBlock = content.Load&lt;Texture2D&gt;("blue-topleft-block");
          this._BlueTopRightBlock = content.Load&lt;Texture2D&gt;("blue-topright-block");
          this._RedBottomLeftBlock = content.Load&lt;Texture2D&gt;("red-bottomleft-block");
          this._RedBottomRightBlock = content.Load&lt;Texture2D&gt;("red-bottomright-block");
          this._RedTopLeftBlock = content.Load&lt;Texture2D&gt;("red-topleft-block");
          this._RedTopRightBlock = content.Load&lt;Texture2D&gt;("red-topright-block");
          this._YellowBottomLeftBlock = content.Load&lt;Texture2D&gt;("yellow-bottomleft-block");
          this._YellowBottomRightBlock = content.Load&lt;Texture2D&gt;("yellow-bottomright-block");
          this._YellowTopLeftBlock = content.Load&lt;Texture2D&gt;("yellow-topleft-block");
          this._YellowTopRightBlock = content.Load&lt;Texture2D&gt;("yellow-topright-block");
          this._GreenBottomLeftBlock = content.Load&lt;Texture2D&gt;("green-bottomleft-block");
          this._GreenBottomRightBlock = content.Load&lt;Texture2D&gt;("green-bottomright-block");
          this._GreenTopLeftBlock = content.Load&lt;Texture2D&gt;("green-topleft-block");
          this._GreenTopRightBlock = content.Load&lt;Texture2D&gt;("green-topright-block");
  
  
  
      }
  </code></pre>
  
  <p>And this is where I stumble up on my main problem. Should I load the content like this? And if so how am I supposed to refer to the texture in the textureArray so that the numbers correspond with the textures they are supposed to have in my 2DArray?</p>
  
  <p>I was thinking of making a nested for loop that places all the sprites in the right position since the board is 15 X 15 sprites (a total of 225).
  And also should I use a foreach statement in my “public void Draw(SpriteBatch spriteBatch)” metod?</p>
  
  <p>I really hope someone can give me some pointers they will be very much appreciated!</p>
  
  <p>Best regards!</p>