On Jun 1, 11:53 am, Ben Sizer <[EMAIL PROTECTED]> wrote: > On Jun 1, 8:51 am, dodgyville <[EMAIL PROTECTED]> wrote: > > > I'm interested in how people and saving their game states. Ideally I'd > > love to just pickle the entire "game" object. In pygame this doesn't > > work because of the image resources, but maybe it's different in > > pyglet? > > It would seem to me to be quite wasteful to be pickling static > resources such as images as part of the game state, anyway. Perhaps a > clear division between the game's 'model' (ie. the things that change > in the game logic) and the game's 'view' (ie. the renderables, the > audio, and other interface concerns that are typically static) could > help you in using pickling for this task.
The model-view separation is useful, but it doesn't always go far enough in this case. It was our experience on Robot Underground that it's best to have a separation between "persistent" game state (the bits you want to pickle), and "dynamic" game state (the bits you don't). So, for example, in Robot Underground the persistent game state consists of the current state of the game's plot, your inventory, your character level, and which map you're on. Dynamic game state includes things like position on the map, current energy and health levels, state of all enemies and NPCs, etc. In the Robot Underground case, persistent state is stored in a pair of objects (PlotState and RobotState), while dynamic state lives in a large hierarchy of objects. This means that pickling is easy, but that we don't store unnecessary data. In particular it means that slight changes to the game don't invalidate old savegames. -- Martin O'Leary http://www.supereffective.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
