On May 8, 2:22 am, Andreas Grätz <
andreas...@googlemail.com> 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