On May 8, 2:22 am, Andreas Grätz <[email protected]> wrote:
> has anyone an example for gamestate management for pyglet. In C++ I use a
> singleton, is there something similar here?

Modules are effectively singletons in Python. Here's a rough example:

  gamestate.py:
  # empty module

  a.py:
  import gamestate
  gamestate.loaded_a = True
  gamestate.foo = 'bar'

  b.py:
  import gamestate
  gamestate.loaded_b = True
  gamestate.foo = 'BAZ'

  main.py:
  import a
  import b
  import gamestate
  print 'Loaded A? %s Loaded B? %s' % (gamestate.loaded_a,
gamestate.loaded_b)
  print 'gamestate.foo = %s' % gamestate.foo

-- 
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.

Reply via email to