Original Post
Hello,
Thanks for looking. I hope this is enough information to describe my problem.
I'm not having any compile errors. Must be logic.
Basically the purpose of this array is to draw a 2dimensional grid of blocks...
I initialize this array:
Each character will designate a block that I am drawing. If it is a blank space, i don't want to draw a block on the screen. If a certain array element is a 1, I want to draw a block there. So the array above should draw a border of blocks around the gamefield. (with no top)
Well, this is my loop where I draw the blocks.
The problem is, EVERY block is drawn. Even all of the spaces. It should draw only the outside border of ones.
If I change the If statement to:
if(gfield[row][col] == ' ')
It draws NO blocks.
Any ideas where my logic error could be?
I have individually placed the drawing blocks in each location so I know my drawing routine (drawBlocks) is fine. The problem has to be in one of these sections of code. Any ideas?
Any help would be greatly appreciated.
Thanks...
-Dennis
EDIT: Added source tags.
[edited by - anachronism on December 18, 2002 10:39:10 PM]
char gfield[17][12] =
{{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','1'},
{'1','1','1','1','1','1','1','1','1','1','1','1'}};
void gamefield::drawfield(void) {
for(int row = 0; row <= 11; row++) {
for(int col = 0; col <= 16; col++) {
if(gfield[row][col] != ' ') {
drawBlock((float)row, (float)col, -20.0f);
}
}
}
}