Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a game that needs to save a lot of detailed data (exact trajectories of some entities) to an external file. I want to save drive space and bandwidth by compressing it, but I've never done this, so I don't know if there is a preferred way to do it.

Of course the compression-decompression should not affect the speed of the game too much.

share|improve this question
What language are you using? – Richard Marskell - Drackir Aug 31 '11 at 11:35
up vote 8 down vote accepted

The zlib library has bindings for most programming languages, and is quite fast. However, you should compare various comperssion algorithms, because one algorithm may achieve better compression rates on your kind of data than on the general case.

share|improve this answer

One, possibly extreme way of compressing data is to record only the steps/inputs used to create it. Something like what ModNation Racer does (curse those long loading times as it re-creates the track). (Google for videos of the track editor in ModNation Racer).

i.e. if i was storing some terrain, i'd store all the manipulations starting from a flat plain. i.e. apply the volcano shaped brush with this force, here. Apply the terrain smoothing operation over this area, with this force. Add my predefined object here. Using bezier-curve-like curves with 'key-frames' to construct an entire track/flight path/whatever.

Many other games do this sort of thing not just for level loading, but for gameplay too, by making the game deterministic, sending only player inputs (i think PixelJunk Shooter 2 does this).

share|improve this answer

Your Answer


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.