Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

werdy666

loadin in a map and rendering it??

This topic is 5752 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having trouble loading in a map i made with mappy32 and displaying it using opengl. I appear to get rubbish instead of my map i created. here is my map loading function and rendering function. If someone could tell me where i am going wrong it would be greatly appreciated! map loading
  
	int value1=0;
	ifstream load;
	load.open("maze1.map", ios::binary);
	if (load.fail())
		return false;
	// map size info above...


		for (int i = 0; i <28; i++) 
			{
			for (int j = 0; j <25; j++) 
				{
				load.read((char*)&value1, 1);
				mapdata[i][j] = value1;
				}
			}
		// map data is now in mapdata[x][y]

		
	load.close();
  
rendering....
  
	for (int j=0;j<28;j++)
		{
		for (int k=24;k>-1;k--)
			{
			glBindTexture(GL_TEXTURE_2D, texture[(mapdata[j][k])].texID);
			glBegin(GL_QUADS);
				glTexCoord2d(0.0,1.0);
				glVertex3f(j-0.5f, -k+0.5f, 0.0f);
				glTexCoord2d(1.0,1.0);
				glVertex3f(j+0.5f, -k+0.5f, 0.0f);
				glTexCoord2d(1.0,0.0);
				glVertex3f(j+0.5f, -k-0.5f, 0.0f);
				glTexCoord2d(0.0,0.0);
				glVertex3f(j-0.5f, -k-0.5f, 0.0f);
			glEnd();
			}		
		}
  
mapdata[28][25] is an array i create. I am sticking with the one size map for the time being. the map file is just saved with mappy32 and each byte represents a tile. At this stage there are only 2 tiles. So its either 0 or 1 that gets passed into mapdata[][]. If u need more code just ask! Werdy666

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!