Hello, I registered here to ask for some help about a small problem that I don't know how to solve.
I am making a videogame in C. As you know, videogames requieres a lot of data like pictures and sound that needs to be loaded in the application. Actually, what I am doing is reading the bitmaps or wavs directly from disk, but this requires a real lot of extra files. Furthermore, those files could be stolen by anyone or easily replaced, something I am not interested in.
So, my idea was to include all this data inside the compiled file. For now an executable for windows, but for porting reasons, it must not be windows' dependant.
My solution to this is to autogenerate a header file containing all the data as an array of bytes for each file, so, instead of loading the bitmap from disk, I ask a function to retrieve the data of the desired "file".
The problem is that I don't really know how to do this properly. My idea is to have a generator application that reads the required files and dumps the data into a .h file like:
char tilesetPictureData [0][]= "56fm32º... ";
char tilesetPictureData [1][]= "56fm32º... ";
...
Then, import this header in the main application and then have another function:
char* retrieve_tileset(int tileset)
That returns me back the chunk of data of the desired object.
This method could make that the whole data is included in the final executable, but probably it will be included in memory too, and that's not something I can afford. At the loading of each level in game I should free the data from the previous tileset and load the new tileset data.
I need to know how can I make a data array that is not loaded in memory when the application runs, and how to retrieve that data without having the whole data arrays loading at once.
Thank you very much and sorry if I didn't explain correctly. I will answer any question.