[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] map format



On Tuesday 19 December 2006 04:41, spotter . wrote:
> On 12/18/06, Chris Smith <maximinus@xxxxxxxxx> wrote:
> > I generally make the map file as simple to read and change in a text
> > editor as I can. This generally makes the python code to parse the file a
> > bit more complex, but since this is done only once at start-up I don't
> > notice any speed issues.
> >
> > Another way of doing it is to write a simple map loader that then pickles
> > the data structure and saves it, and then in your game, load the pickle
> > file.
>
> Pickling sounds awesome, looking at some tutorials on the web. It
> would be a good choice if the editor was made in python, and it could
> be pickled. Text just makes it simpler to start, but pickling would
> probably be faster in the end.

Pickling is good, but can create code maintenance problems as your data files 
store references to actual classes in modules.

Consider reducing your data down to Python builtin types (list, dict, etc.) 
and use the marshal module instead. It's faster and has none of the potential 
hassles of pickling.


    Richard