Jump to content
  • Advertisement

Archived

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

MindWipe

Help me to make save and load a simple map.

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

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
Advertisement
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
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

Share this post


Link to post
Share on other sites
WOW!!! IT works. THANKS!! Thanks alot.
Often when I get help I can''t get it to work.
But this worked. Thanks again!


MindWipe

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!