Sign in to follow this  
1Bit

Save Map

Recommended Posts

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

[code]
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++;
[/code]

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
Monkan    1087
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
1Bit    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this