[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Pickling?



Gerrit Holl wrote:
For a Rect, this is actually so basic that I think the default Rect
should be able to do the task described here. A rect can be recreated
using a 4-integer-sequence, with the __getstate__ and __setstate__.
at one point i tried to add pickling support for Rect objects. i tried something with the __getstate__ functions, but it didn't end up working. (couldn't find docs on these). I'd definitely add them back in.

as for pickling images, it's a slightly different story since there is so much data. in python it is very easy to compress image data down to a reasonable size (although not the best size).

i wrote this code awhile ago that embeds an image into a .PY source file. it could easily be changed to send it to a pickle as a tuple of 4 integers and strings. in fact, in a pickle the image would not need to be base64 encoded, so it would end up smaller.

it seems what you'd really want is to just save an image filename though. if you have many sprites referencing the same images it would get embedded many times. and what about sprites that use many images for animation?


oh, and someone asked about the UserRect, it got moved to the code repository awhile back (it turns out you're not insane, heh)
http://www.pygame.org/pcr/userrect/index.php



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org