On 14 July 2011 19:33, greenmoss <ktygoo...@yoderhome.com> wrote:

> On Jul 14, 11:53 am, Tristam MacDonald <swiftco...@gmail.com> wrote:
> > On Thu, Jul 14, 2011 at 10:43 AM, greenmoss <ktygoo...@yoderhome.com>
> wrote:
> > > Are there any plans to make pyglet objects amenable to
> > > pickling?
> >
> > I am not sure I see a strong case for needing to pickle sprite objects.
> The
> > OpenGL data/state that would need to be reconstructed on unpickling is
> > significant enough to be troublesome (i.e. can't unpickle without a valid
> > OpenGL context).
> >
> > I would generally recommend that you separate game data from graphics
> data,
> > and design your engine such that you can reload the graphics data based
> on
> > the game data.
>
> Let me preface my response by saying that I'm inexperienced, so I
> could well be taking a suboptimal approach. That being the case, the
> most logical way to handle game and graphics data for an in-game
> object would IMHO be to attach it to a single python object. This in
> turn leads to manual getstate/setstate overrides, extra code, etc.
>
> Is there some other way that people handle this type of situation?
>
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To post to this group, send email to pyglet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> pyglet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.
>
>

The preferred way to do this is to have one python object that contains a
sprite PROPERTY. In design, this is it:

  class Object:
      def __init__(self,properties):
          #set whatever you need except graphics
          self.sprite = Sprite(graphics properties)
          #set graphics properties

And either have 'wrappers' for the functions you need, for example:

      def draw(self,options):
          self.sprite.draw(options)

Or just make sure you're calling the SPRITE'S functions, and not your game
objects. Separating graphics and game code is the basis for any graphics
coding more advanced than a hello world program, that you would intend to
develop further.

If you still have trouble with the design/practice of it, reply and I will
make a tutorial detailing the process as much as possible.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to pyglet-users@googlegroups.com.
To unsubscribe from this group, send email to 
pyglet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to