Jump to content
  • Advertisement
Sign in to follow this  
1Bit

Save Map

This topic is 2559 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

So I have this map editor and I'm trying this function but it freezes the game while it is doing it...


int ID = 0;

for (int y=0;y<MapH;y++)
{
for (int x=0;x<MapW;x++)
{
if (TileList[ID].TypeID == None)
{
ID++;
continue;
}

int TileX = MapX + (x * TileSize); int TileY = MapY + (y * TileSize);
int TileSetX = (TileList[ID].TileID % TileSetWidth) * TileSize;
int TileSetY = (TileList[ID].TileID / TileSetHeight) * TileSize;



Render(TileSet, Display, TileX, TileY, TileSetX, TileSetY, TileSize, TileSize);
ID++;


can anyone please tell me how I can go about saving the "map"...

I know it should be something like: fprintf(fp, "%d ", TileList[ID].TileID);

right?

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I'm not sure if you posted all the code you were meant to and did not explain very well what answer you want.
The code that is posted there should not freeze unless something in your Render() function freezes.

If you want to know how to save to file then look up file I/O, you could do it the C way or the C++ way which ever you prefer, I personally use C++ but a quick google should give you answers. fprintf is C so just google file I/O C and you should get lots of info, you'll need to open a file for writing before the fprintf.

If you wanted to know something specific about saving a map in a certain format or something then say.

Share this post


Link to post
Share on other sites
sorry I didn't explain my self well enough, but I solved it, thanks anyways, I changed it to C++ I/O but since this is temporary map "storage" I don't really care... but thanks anyways

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!