Archived

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

MindWipe

Help me to make save and load a simple map.

Recommended Posts

Ok. I''m used to Basic andf VB that''s why I have a problem now. I want to make a map ie. 10 x 10 tiles. I use an array like Map[10][10]. And then if for example: Map[4][9]=12 then the tile at (4,9) is a rock. If it''s 10 it might be a tree, or something. Well, I want to know how I can save all 10x10 tiles in a file. And then load it again. So that I can make a map editor. And get it to load the map in my game. How do I do that? Please help. I''m greatful for any help.

Share this post


Link to post
Share on other sites
Thats piss:

To Save:

void SAVE_MAP(char *fname)
{
FILE *fptr;
fptr = fopen(fname,"wb");
fwrite(Map,(10*10),1,fptr);
fclose(fptr);
}

To Load:

void LOAD_MAP(char *fname)
{
FILE *fptr;
fptr = fopen(fname,"rb");
fread(Map,(10*10),1,fptr);
fclose(fptr);
}

There you go.

- Make sure you #include

Thats my 2 seconds , eh I mean cents!

/Memir

Edited by - Memir on July 23, 2000 9:54:52 AM

Share this post


Link to post
Share on other sites