10
\$\begingroup\$

I've recently made a basic Space Invaders clone, in C++, using the Allegro 5 framework. After I finished, I realized I had about 10 sprites, and 13MB worth of DLLs; some of the players didn't even have the mingW DLLs, which was making the game very confusing.

How do I pack all my resources in a way that I can easily add and remove data to my game, and to reduce the size taken by the resource, basically placing them in one spot? I'm using codeblocks.

\$\endgroup\$
  • 1
    \$\begingroup\$ How do you understand the term resources? Assets like images, sounds, ... or do you include DLLs in this term? \$\endgroup\$ – Christian Ivicevic Sep 10 '12 at 16:17
  • \$\begingroup\$ I'd prefer if I could fit DLLs as well because I have lots of those. \$\endgroup\$ – Bugster Sep 10 '12 at 16:29
  • \$\begingroup\$ My first idea would be to find a suitable library like the (quite outdated...) zziplib to store all my usual assets in a zip file and then load them in my game through a custom content pipeline foe the engine. What you are basically looking for at the beginning is a way to load files from a zip file to memory to be able to use them in your game. Concerning the dlls it is quite difficult because they usually have to be in the same dir as the executable or the Windows or System32 dir which is NOT recommended! How about a SFX archive to extract to TEMP and run from there? \$\endgroup\$ – Christian Ivicevic Sep 10 '12 at 16:33
  • 3
    \$\begingroup\$ Are you asking about how to use an installer? Because DLLs aren't resources. \$\endgroup\$ – Nicol Bolas Sep 10 '12 at 16:59
13
\$\begingroup\$

It seems like there are two challenges you are facing here: distribution, and asset packaging.

Distribution

Package up your entire application into directories as you see fit, then place the top-level directory into a .zip file. Distribute that .zip file. When your users extract the zip, they will have a folder with everything they need ready to run the game.

How do you place your files?

  • Your .dlls usually need to be in the same directory as the executable (there are exceptions, but for the sake of simplicity...)
  • Your assets (images, audio) can be wherever you want them, though if you move them in reference to your executable you'll have to modify you resource-loading code to take this into account.

I usually do something like this:

MyGame\              // top level directory holds entire progrma
  bin\               // dlls go here along with the compiled exe
  res\               // game resources top level directory
    music\
    sound-effects\   
    voice\
  cfg\               // default configuration files (user-configs go in user directory)
  MyGame.lnk         // shortcut to compiled exe

Asset Packaging

You can use some sort of compression library (zlib, lzo) to compress all of your game resources (the above res\ directory) into a single file. Then you need to use the same compression library to extract the contents of your resources, in real-time, in order to load your assets into your game.

Then what happens when you want to patch your assets? Then you have to either: compile a whole new assets file and distribute that to your users (so they are essentially re-downloading what they already have, plus the handful of additions), or you have to build an updater (another program to maintain) and deal with the fact that things can go wrong and your asset file will get corrupted...

Honestly, it's not exactly trivial to make that work and I don't see the pay-off in your situation. A simple directory should be enough to encapsulate your 10 sprites and it's a whole lot easier to add and patch things: just need to download them to the right directory and done.

Building an Installer

This is assuming you're targeting Windows... once you have the above down, you can work on building an installer for your game. I would avoid at all costs the ClickOnce methods that Visual Studio supports. It's not your typical Windows installer and comes with it's own set of quirks.

Take a look at this StackOverflow question - it contains a set of helpful links to installer packages you can use. A lot of people these days seem to like WiX. I've never used it myself. In addition, AdvancedInstaller and InnoSetup are both popular choices.

\$\endgroup\$
  • 1
    \$\begingroup\$ Thanks for this answer, now I have a basic idea how I should distribute my game. \$\endgroup\$ – Bugster Sep 10 '12 at 18:17
  • 1
    \$\begingroup\$ Don't use WiX. It will hurt your head and kill your family. \$\endgroup\$ – Ray Dey Sep 10 '12 at 19:55
  • 1
    \$\begingroup\$ There's another option - there can be more than one asset package. Something like "resources.pak, patch1.pak, patch1337.pak, .." would then be a way to store patch data. There would be no need to modify the original package, just make the engine capable of detecting and ordering patch packages. \$\endgroup\$ – snake5 Sep 10 '12 at 20:04
0
\$\begingroup\$

You might be able to statically link some of the libraries instead of including the dll’s. If and how is different for every library though.

\$\endgroup\$
-1
\$\begingroup\$

You could use a software like Enigma to pack your files and save them into a single .dat. You would need to change the folder of your launcher.

\$\endgroup\$

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.