Random89

04-27-2009, 09:41 AM

Basically I am trying to make a maze in OpenGL. The problem I am having is that I am using array lists for the maze map but it doesn't create the shape I want. The code is below:

float wallX[13] = {25, 15, 35, 55, 45, 45, 65, 15, 65, 55, 45, 35, 25}; //Array for columns

float wallY[26] = {10, 25, 15, 45, 15, 35, 15, 45, 15, 25, 35, 55, 35, 45, 55, 75, 55, 75, 65, 75, 65, 85, 75, 85, 95, 105}; //Array for what part of the columns are coloured, each pair is a line

float pi = 0;

int WallXCo = 0;

int WallYCo = 0;

float WallXCo1;

float WallXCo2;

float WallYCo1;

float WallYCo2;

for(pi = 0; pi < 13; pi++)

{

WallXCo1 = wallX[WallXCo] - 1.25;

WallXCo2 = wallX[WallXCo] + 1.25;

WallYCo1 = (wallY[WallYCo] - 1.25) * -1;

WallYCo2 = (wallY[WallYCo + 1] + 1.25)*-1;

drawWall(WallXCo1, WallYCo1, WallXCo2, WallYCo2);

WallXCo = WallXCo + 1;

WallYCo = WallYCo + 2;

}

void drawWall(float WallXCo1, float WallYCo1, float WallYCo2, float WallXCo2)

{

glColor3f(1,0,1);

glBegin(GL_POLYGON);

glVertex2f((WallXCo1),(WallYCo1));

glVertex2f((WallXCo2),(WallYCo1));

glVertex2f((WallXCo2),(WallYCo2));

glVertex2f((WallXCo1),(WallYCo2));

glEnd();

}

This is just the code for the vertical sections of the map. Each X coordinate has two Y coordinates (WallX[0] equates to wallY[0] and wallY[1] making a line 5 in width between the two points).

However instead of any sort of map coming out of it I just get a mass of green with no shape. Anyone know what I am doing wrong?

float wallX[13] = {25, 15, 35, 55, 45, 45, 65, 15, 65, 55, 45, 35, 25}; //Array for columns

float wallY[26] = {10, 25, 15, 45, 15, 35, 15, 45, 15, 25, 35, 55, 35, 45, 55, 75, 55, 75, 65, 75, 65, 85, 75, 85, 95, 105}; //Array for what part of the columns are coloured, each pair is a line

float pi = 0;

int WallXCo = 0;

int WallYCo = 0;

float WallXCo1;

float WallXCo2;

float WallYCo1;

float WallYCo2;

for(pi = 0; pi < 13; pi++)

{

WallXCo1 = wallX[WallXCo] - 1.25;

WallXCo2 = wallX[WallXCo] + 1.25;

WallYCo1 = (wallY[WallYCo] - 1.25) * -1;

WallYCo2 = (wallY[WallYCo + 1] + 1.25)*-1;

drawWall(WallXCo1, WallYCo1, WallXCo2, WallYCo2);

WallXCo = WallXCo + 1;

WallYCo = WallYCo + 2;

}

void drawWall(float WallXCo1, float WallYCo1, float WallYCo2, float WallXCo2)

{

glColor3f(1,0,1);

glBegin(GL_POLYGON);

glVertex2f((WallXCo1),(WallYCo1));

glVertex2f((WallXCo2),(WallYCo1));

glVertex2f((WallXCo2),(WallYCo2));

glVertex2f((WallXCo1),(WallYCo2));

glEnd();

}

This is just the code for the vertical sections of the map. Each X coordinate has two Y coordinates (WallX[0] equates to wallY[0] and wallY[1] making a line 5 in width between the two points).

However instead of any sort of map coming out of it I just get a mass of green with no shape. Anyone know what I am doing wrong?