Skip to main content
GameDev.net gamedev.net
🔒 Locked

Scrolling Map Problem

Started by FlorianapoliS Aug 5, 2002 at 1:29 AM 0 replies 200+ views
Original Post
FlorianapoliS
FlorianapoliS
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:
  
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);
}	
  
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.