9
\$\begingroup\$

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.

\$\endgroup\$
1

2 Answers 2

8
\$\begingroup\$

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.

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

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).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .