Moon Rabbits
02-03-2007, 04:47 PM
I'm programming a breakout clone in C++ using Allegro to help me framiliarize myself with the Allegro graphics library, but I'm having a few problems.
The bricks are initialized like this:
for(int i = 0; i < NUM_COLUMNS; i++)
{
for(int j = 0; j < NUM_ROWS; j++)
{
bricks[i][j].x = BRICK_WIDTH + (i*BRICK_WIDTH) + (i*3);
bricks[i][j].y = BRICK_HEIGHT + (j*BRICK_HEIGHT) + (j*5);
bricks[i][j].col[0] = 255;
if(j < (COL_CHANGE_INTERVAL*2))
{bricks[i][j].col[0]=0; bricks[i][j].col[1]=255;}
if(j < COL_CHANGE_INTERVAL)
{bricks[i][j].col[0]=0; bricks[i][j].col[1]=0; bricks[i][j].col[2]=255;}
}
}
(Ignore the bolded stuff) Where NUM_ROWS and NUM_COLUMNS are defined as 9 and 10 respectively. BRICK_WIDTH and BRICK_HEIGHT are defined as 50 and 15 respectively.
However, when I run the program only 9 columns are drawn when I call the function to draw my bricks. Why is this?
The bricks are initialized like this:
for(int i = 0; i < NUM_COLUMNS; i++)
{
for(int j = 0; j < NUM_ROWS; j++)
{
bricks[i][j].x = BRICK_WIDTH + (i*BRICK_WIDTH) + (i*3);
bricks[i][j].y = BRICK_HEIGHT + (j*BRICK_HEIGHT) + (j*5);
bricks[i][j].col[0] = 255;
if(j < (COL_CHANGE_INTERVAL*2))
{bricks[i][j].col[0]=0; bricks[i][j].col[1]=255;}
if(j < COL_CHANGE_INTERVAL)
{bricks[i][j].col[0]=0; bricks[i][j].col[1]=0; bricks[i][j].col[2]=255;}
}
}
(Ignore the bolded stuff) Where NUM_ROWS and NUM_COLUMNS are defined as 9 and 10 respectively. BRICK_WIDTH and BRICK_HEIGHT are defined as 50 and 15 respectively.
However, when I run the program only 9 columns are drawn when I call the function to draw my bricks. Why is this?