Even though hard drives are getting bigger and Internet connection speeds are increasing at a dizzying rate, not everyone has access to the latest technology. The smaller you can make your software, the more you increase the amount of people that can play it – thus increasing downloads.
Use the Right Tool for the Right Job
If you're compressing images, choose the right format for the right job. PNG is a lossless format that is much better at compressing pixel art images than photographs. JPG can leave a lot of “artifacts” on these kinds of images, and is better suited for compressing photos or painted artwork. Choosing the right format not only shrinks the size of your application, but helps to maintain the quality of the final product.
Shrink Executables and Libraries
You can generally shrink you .exe and .dll files by around 50% by using UPX, with no discernible change in performance.
Note: Always compress executables after icons and resources have been added, as adding resources to a compressed executable can result in programs working strangely (or not at all).
If you're using PNG images, pngcrush is an essential application to have installed. It has many different levels of compression available and can generate considerable space savings. Perhaps the most useful feature is the “brute force” option, which will try over 100 different combinations to create the smallest possible image file.
Shrink Music and Audio
Using OGG or OXM for music can generate large savings when compared to raw formats such as WAV and XM. OGG is well suited to sound samples and music, and can make a huge difference if the correct quality settings are chosen. It's usually best to try a few settings and listen to the results to see which quality to use, as some qualities work better for different kinds of sounds.
OXM is a compressed version of the XM music format, a MIDI like format that uses its own samples. The OXM format compresses the samples using the OGG codec, and can easily shrink a track by 70% or more with virtually no audible differences.
OggEnc is a command line tool for encoding OGG files, whereas OggDrop is a GUI application that supports drag and drop. OggMod is a tool for compressing XM files into OXM.
Pack Your Data
If your game uses any kind of custom data definitions, such as text or xml level definitions, you can generate extra savings by compressing them. There are many different compression algorithms, and some are more suited than others. Run Length Encoding (RLE) works well for data that has large areas of sequential data values, but isn't as effective for other formats such as XML. There are plenty of freely available compression libraries, and including zlib and unrar, and most languages have a wealth of examples to look at.
Automate the Process
Manually compressing all of your media can be a slow and tedious process, and can generally be left until the game's release. At the simplest level, you can place all of the commands into a Windows batch file and run it once you've compiled your software. Other options include using build software, which is covered in more detail in the recent build tools article.