Advertisement

Help me to make save and load a simple map.

Started by July 23, 2000 08:16 AM
2 comments, last by MindWipe 24 years, 5 months ago
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.
"To some its a six-pack, to me it's a support group."
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
Flash Pool - Pool/Billiards game for Facebook (developed by Memir).
Advertisement
OOps, forgot to ask what is Map[10][10]?

you should make it:

BYTE Map[10][10]; // (And globally) - so those to funcos above work

/Memir

Flash Pool - Pool/Billiards game for Facebook (developed by Memir).
WOW!!! IT works. THANKS!! Thanks alot.
Often when I get help I can''t get it to work.
But this worked. Thanks again!


MindWipe
"To some its a six-pack, to me it's a support group."

This topic is closed to new replies.

Advertisement