Basically, I'm storing the Map in a structure that looks something like
struct MapStruct {
Int l1; // Layer 1 of the map
Int l2; // Layer 2 of the map
} Map[500][500]; // to create an initial 500x500 tile map
Layer 1 is the bottom layer of tiles, and Layer 2 is the top layer of tiles. Right now the only thing that i have in the MAP.DAT file is the tiles that are stored in layer 1 and the tiles that are stored in layer2. Eventually, i'm going to add a header to the beginning of the map that includes the height and width of the map, the name of the map, and some other information
I saved the map into the MAP.DAT file using binary output. The code looks like this...It should be pretty self-explanitory
void SaveFile() {
FILE* iFile;
if ((iFile = fopen("MAP\\MAP.DAT", "wb")) == NULL)
{
fprintf(stderr, "Cannot open output file.\n");
}
fwrite(&Map,sizeof(Map),1,iFile); //Read the entire map into the
struct
fclose(iFile);
};
I load the file using the same code as above except changing the fwrite to fread and the "wb" to "rb". Reeeally easy.
Accessing something in the map file is simple. to display what tile is in coordinate 3,2 (3 over and 2 down) in layer 1, you could use the code:
printf("%d",Map[3][2].l1);
That's about all the info i can think of right now relating to this topic. More will come later!