Original Post
Hey, I''m trying to make a little overhead racer (GTA style) game in OpenGL, but I''ve got a little stuck on drawing the map:
This is what I have now, I''m probably miles off but currently it just draws pieces of the map all over the shop?
Need to know about any sections of my code just ask
int DrawMap(int xpos, int ypos)
{
int tile, x, y, drawx, drawy;
drawx = 15; // Position to draw on the screen
drawy = -15;
for (x = xpos; x > (xpos - 30); x--) // Tiles around the car to draw
{
drawx++;
drawy = -15;
for (y = ypos; y < (ypos + 30); y++)
{
drawy++;
tile = MapArray[x][y].tile;
if((tile > 7) || (tile < 0))
{
tile = 7;
}
glBindTexture(GL_TEXTURE_2D, texture[tile]);
if (MapArray[x][y].driveable)
{
DrawCube((float)x, (float)-y, 2, 1, 1); // If not driveable draw solid textured cube
}
else
{
glBegin(GL_QUADS); // Draw flat tile
glTexCoord2f(0.0f, 0.0f); glVertex3f(float(drawx), float(-drawy), 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(float(drawx + 1), float(-drawy), 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(float(drawx + 1), float(-drawy - 1), 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(float(drawx), float(-drawy - 1), 0.0f);
glEnd();
}
}
}
return(1);
}