title: Implementing a 2D Map
body: <p>I posted a Q. earlier about arrays and the replies lead me to change my game design. I'm building a 2D game map from tiles (Cells). I need to add a pen line to some cells, representing a wall you cannot pass through. This pen line is represented by Cell.TopWall, Cell.BottomWall etc etc of type boolean as shown in my code. This is my whole app so far. It draws the grid without the pen lines for walls. Take note of commented out code where i have tried different things like stating where the walls go with an array of 0's (no wall) and 1's (walls). My question is, can i get a hint on how to implement the walls where i would like? I hope i have shared enough information about my app. Thanks</p>
  
  <p>Cell.cs</p>
  
  <pre><code>    using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace Map
  {
      public class Cell : PictureBox
      {
          bool LeftWall; 
          bool TopWall; 
          bool RightWall;
          bool BottomWall;
      }
  }
  </code></pre>
  
  <p>Form1.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace Map
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
          /// &lt;summary&gt;
          /// Array of tiles
          /// &lt;/summary&gt;
          //PictureBox[,] Boxes = new PictureBox[4,4];
          Cell[,] Map = new Cell[4,4];
  
          /*int [][] Boxes = new int[][] {
        new int[] {0,0}, new int[] {1,0,0,1},
        new int[] {1,0}, new int[] {1,0,1,0},
        new int[] {0,1}, new int[] {0,0,0,1}, 
        new int[] {1,1}, new int[] {1,1,1,0}, 
        new int[] {2,0}, new int[] {1,1,0,0},
        new int[] {2,1}, new int[] {0,0,0,1}, 
        new int[] {3,1}, new int[] {1,0,1,0}, 
        new int[] {0,2}, new int[] {0,0,1,1}, 
        new int[] {1,2}, new int[] {1,0,1,0}, 
        new int[] {2,2}, new int[] {0,1,1,0}};*/
  
          #region Runtime load
          /// &lt;summary&gt;
          /// Build the map when window is loaded
          /// &lt;/summary&gt;
          /// &lt;param name="sender"&gt;&lt;/param&gt;
          /// &lt;param name="e"&gt;&lt;/param&gt;
          private void Form1_Load(object sender, EventArgs e)
          {
              BuildMap();
          }
          #endregion
  
          #region Build grid
          /// &lt;summary&gt;
          /// Draw every tile on the map
          /// &lt;/summary&gt;
          public void BuildMap()
          {
              for (int row = 0; row &lt; 3; row++)
              {
                  for (int column = 0; column &lt; 3; column++)
                  {
                      DrawBox(row, column);
                  }
              }
              //draw the exit box
              DrawBox(1, 3);
          }
          #endregion
  
          #region Draw
          /// &lt;summary&gt;
          /// Draw one tile
          /// &lt;/summary&gt;
          /// &lt;param name="row"&gt;&lt;/param&gt;
          /// &lt;param name="column"&gt;&lt;/param&gt;
          public void DrawBox(int row, int column)
          {
              Map[row, column] = new Cell();
              Map[row, column].Height = 100;
              Map[row, column].Width = 100;
              Map[row, column].BorderStyle = BorderStyle.FixedSingle;
              Map[row, column].BackColor = Color.BurlyWood;
              Map[row, column].Location = new Point((Map[row, column].Width * column), (Map[row, column].Height * row));
              this.Controls.Add(Map[row, column]);
  
              System.Drawing.Pen myPen;
              myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
              System.Drawing.Graphics formGraphics = this.CreateGraphics();
  
  
              //formGraphics.DrawLine(myPen, 0, 0, 200, 200);
              //myPen.Dispose();
              //formGraphics.Dispose();
          }
          #endregion
      }
  
  
  }
  </code></pre>