Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've recently made a basic space invaders clone in C++ using the Allegro 5 framework. It took me a long time, but after I finished, I realized I had about 10 sprites, and 13MB worth of DLLs (Some of the people didn't even have the mingW dlls) which were making people who played the game very confused.

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

share|improve this question
1  
How do you understand the term resources? Assets like images, sounds, ... or do you include DLLs in this term? –  Christian Ivicevic Sep 10 '12 at 16:17
    
I'd prefer if I could fit DLLs as well because I have lots of those. –  Bugster Sep 10 '12 at 16:29
    
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? –  Christian Ivicevic Sep 10 '12 at 16:33
3  
Are you asking about how to use an installer? Because DLLs aren't resources. –  Nicol Bolas Sep 10 '12 at 16:59
add comment

2 Answers

up vote 7 down vote accepted

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.

share|improve this answer
    
Thanks for this answer, now I have a basic idea how I should distribute my game. –  Bugster Sep 10 '12 at 18:17
    
Don't use WiX. It will hurt your head and kill your family. –  Ray Dey Sep 10 '12 at 19:55
    
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. –  snake5 Sep 10 '12 at 20:04
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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