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.
Answer
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.
No comments:
Post a Comment