zacharycarter / zengine

2D | 3D Game development library
156 stars 13 forks source link

Resource loading system #31

Open define-private-public opened 7 years ago

define-private-public commented 7 years ago

This is a TODO for much later when we have some more of the core functionality done, but it would be good to have some sort of resource loading system in place. I know that many other engines (such as Urho3D) and app frameworks (like Qt) have systems where you can define resources/assets in something like an XML file and then in your code query a key (instead of the actual filename) to get the asset loaded.

This is a must for three main reasons I can think of:

  1. For the case where the filename of a resource has changed, this will mean having to change the source code and force a recompilation. If they only have to change the value of a key-value pair in a text file there is no recompilation, thus saving on unfortunate compile times.
  2. Packaging. Say someone wants to bundle up all of their resources in one flat tarred up file, this will make their life easier for distribution. We would probably need to write a tool to do this though. I'd say to make this a feature for a later release.
  3. Localization. Resources should not be limited to only files, this should include strings of text. In the case of dialogue/story for a game the dev could just hand the resource file off to a translator. I know there is also the sensitive subject of censorship of video games in certain regions of the world. The best example I can think of when shooter games set during WW2 European theatre are distributed in Germany. Certain iconography needs to be scrubbed because of laws.

With this said, I also don't think that this should be forced on the dev to use; though highly recommended for those reasons above.

Are there any existing systems out there for Nim? If not, maybe modeling something after Qt's QResource system might be good.