1

I've hit a wall with this array of rectangles. I was fine with simply a one dimensional array but with one with 4 columns I've just started banging my head on my wall...

I've defined the array as:

private Rectangle[,] brick = new Rectangle[2, 8];

Then these are used in conjunction to that:

int[,] brickLocation = { {0, 0}, {0,21}, {0,42}, {0, 63}, {0, 84}, {0, 105}, {0, 126},
                             {61, 0}, {61,21}, {61,42}, {61, 63}, {61, 84}, {61, 105}, {61, 126} };
bool[] brickLive = { true, true, true, true, true, true, true,
                       true, true, true, true, true, true, true };

And then trying to draw the rectangles through the multi array loop:

for (int i = 0; i < brickLive.Length; i++)
{
    for (int j = 0; j < brickLive.Length; i++)
    {
        if (brickLive[i] == true)
        {
            brick[i, j] = new Rectangle(brickLocation[i, 0], brickLocation[i, 1], brkLength, brkHeight);
                    brickPaper.DrawRectangle(brickPen, brick[i, j]);
        }
        else
        {
            continue; //move onto next brick
        }
    }
}

It's stopped working and I can't think what I can do.... Can anyone help?

Codor
  • 17,447
  • 9
  • 29
  • 56
EnglischerZauberer
  • 237
  • 1
  • 2
  • 11

1 Answers1

3

To my understanding, in the lines

for (int i = 0; i < brickLive.Length; i++)
for (int j = 0; j < brickLive.Length; i++)

for the loops in the second line you mean to increase j, but you increase i instead.

CSharpie
  • 9,195
  • 4
  • 44
  • 71
Codor
  • 17,447
  • 9
  • 29
  • 56