I am currently looking into implementing a save functionality to a small rpg I have made using the shelve
module which uses pickle
.
After finding out I couldn't pickle pygame surfaces I followed advice suggesting passing a dictionary key instead as my object attribute. Once I had spent hours fixing the game, systematically checking all the surfaces and actually getting the start menu up and running I got a new message error stating pygame clock objects can't be serialized either. Much to my dismay, since, unlike for the surfaces I can't pre create all the clocks I need since I use a lot of them (attack timers, animation timers, AI timers., etc ) all specific to given objects. I.e instead of having one attack timer for all my sprites I have one for each so that I have more flexibility. Furthermore, the number of clock will depend on the number of objects I create, and, to some extent this number is random. I really can't think of a way around while keeping an object oriented structure I.e avoiding generating 1000s timers and linking to objects.
So to recap on the questions I actually have:
1) how can I shelve
pygame timers ?
2) if it is not possible what alternative would you recommend ?
3) before spending anymore time on implementing this save functionality, what other pygame objects are not serializable, or where could I find this information ?
I know I ask a lot but I feel quite frustrated having spent so much time getting those surfaces sorted just to have the same issue with timers and wondering what will be next... Although I guess it's all part of learning ;)