0

I'm creating a 2D game in plain ANSI-C using SDL2. I'm planning to let users create their own graphics. So, to achieve this, I'll use an information file which will hold some data such as Width, Height, X and Y position of each frame. But I have two views of this. One is to use a single file which will hold the information of all graphics. The other is to use one file for each graphic. Which one is faster and cleaner? Or it's just the same?

  • 2
    In addition to the accepted answer below, there is a third option. You could use a format such as zip to have the benefits of both approaches. There is a single file on disk, but users can easily modify individual assets using freely available tools. This is the approach taken in the old Quake series of games and it worked well. – user22815 Apr 17 '14 at 16:22
3

Using one file is cleaner, but also, files have to take up a minimum space (On my disk, 16kb, this is called the cluster size). So if you're creating lots of small files, even if each one is only one byte long, if you have 1000 files, that's nearly 16 megabytes!

It depends on the size of the files stored with each graphic, to summarize:

Multi-File advantages:

  • A corrupted file will not effect all graphics.
  • You don't need to search for the part of the file you want.
  • Clearer code

Single file advantages:

  • You don't have issues with cluster size
  • Potentially faster accessing as you don't need to open multiple files

It also depends if this information will be streamed, or read once at startup. If it's read once at startup, then speed of accessing doesn't matter so much. Personally, if you're going to end up with lots of really small files, I'd go with one larger file, but if you're going to end up with less files of more reasonable sizes, I'd go for a file per graphic

|improve this answer|||||
3

The key here is that you want end users to be able to add graphics. If thats the case, I'd recommend individual files for the graphics, this way customers don't have to edit existing files (and possibly corrupt them), and its easier to distribute art for the game by just copying files into their directory - no need to edit existing files.

|improve this answer|||||
  • Hi, thanks for your answer. This makes me doubt. I'll think this. Thanks again. – cdonts Apr 17 '14 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.