Jump to content
  • Advertisement


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


External Array

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

I’m building a simple array based tile engine. I want to have an outside source to hold my array (E.g. World Map File). If I remember correctly, one way of doing it is; putting the array in a binary file using MSVC, then loading it into memory in my main code. If someone could clear this up for me, and maybe give me a idea of what to do, it would be very much appreciated. Jess,

Share this post

Link to post
Share on other sites
Um... what I think you should do is have world maps. These would store details about your world in a binary, which would be read in by your game. You would have an array and use fopen(), fread(), fclose(), etc., to read in the stuff.

I''ll repeat myself. You store the data in a file, but load it into your array inside your program. For example:

FILE* pInput = fopen("yourfile.dat", "rb");
if (pInput == NULL)
// whoops, it didn''t work!

// load in your file using fread(), fgets(), fscanf(), etc


To create the file, you can use fwrite() and so on. See MSDN for details.

If you want to write your file, the parameter for fopen() is "wb+" (I think, if I remember rightly), meaning open in binary writing mode, and create the file if it doesn''t exist. See 2D Game thingy. This discusses all sorts of tile game issues, and probably does loading too - I haven''t checked.

Alistair Keys

"There are two kinds of people, those who finish what they start and so on."
-- Robert Byrne

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!