PDA

View Full Version : Problem with drawing square sides, help!



blood.angel
11-14-2001, 05:50 AM
Im trying to code a program that creates a 2D maze thats solvable. The way I have so far made it that the maze area is split into squares and each square is an object from a CSquare class (therefore the whole maze in a 2d array of CSquare objects).

Each square object has 4 booleans defining the presence (of lack) of a wall around the circumference of the maze square.

And so far I have only assigned walls to the outer circumference of the whole maze ie the top row of squares in the array has been assigned top walls, the bottom row of squares have been assigned bottom walls etc.

When I draw the maze with the following code the top and left squares of the maze circumference are only drawn, but the bottom and right are not.

Could someone please help?




#define ROWS 10
#define COLUMNS 10

void Draw_Maze()
{
GLfloat cell_width, cell_height;
GLint row, column;
GLfloat start[2] = {0.0, 1.0};

cell_width = 1.0/(GLfloat)COLUMNS;
cell_height = 1.0/(GLfloat)ROWS;


glBegin(GL_LINES);

for(row = 0; row < ROWS; row++)
{
for (column = 0; column < COLUMNS; column++)
{
if(maze_array[row][column].Get_top_wall())
{
glVertex2f(start[0], start[1]);
glVertex2f(start[0]+cell_width,start[1]);
}

if(maze_array[row][column].Get_left_wall())
{
glVertex2f(start[0], start[1]);
glVertex2f(start[0],start[1]-cell_height);
}

if(maze_array[row][column].Get_right_wall())
{
glVertex2f(start[0]+cell_width, start[1]);
glVertex2f(start[0]+cell_width,start[1]-cell_height);
}

if(maze_array[row][column].Get_bottom_wall())
{
glVertex2f(start[0], start[1]-cell_height);
glVertex2f(start[0]+cell_width,start[1]-cell_height);
}


start[0]+=cell_width;
}
start[1]-=cell_height;
start[0]=0.0;
}

glEnd();
}



Ive set up breakpointss and followed the assigning and bottom and right walls are assigned to each square of the array. They dont get drawn for some unknwn reason.

Get_top_wall() etc return true or false if a wall appears there.



[This message has been edited by blood.angel (edited 11-14-2001).]

blood.angel
11-14-2001, 06:21 AM
Ah I have gluOrtho2D(0.0, 1.0, 0.0, 1.0);
And if I set it to above 1.0 the lines are drawn.

But still, how come they are not drawn when the line coords become (0.0, 1.0) and (1.0,1.0)?