Re: Pyglet questions
would something like this help?
import pyglet
from pyglet.window import key
class Test(pyglet.window.Window):
def __init__(self):
super(Test, self).__init__(640, 480, resizable=False, fullscreen=False, caption="Test")
self.clear()
#key input container self.key_input = [] #current menu state self.state = 'stuff1' #load menus self.menus = {'stuff1':stuff1(),'stuff2':stuff2(),'stuff3':stuff3()} #schedule to call update function pyglet.clock.schedule_interval(self.update, .01) def update(self,dt): #update menus self.state = self.menus[self.state].update(self.key_input,self.state) if len(self.key_input) > 0: self.key_input = [] self.draw() def draw(self): self.clear() def on_key_release(self,symbol,modifiers): self.key_input.append(key.symbol_string(symbol) + " release") class stuff1(object): def update(self,key,state): if 'SPACE release' in key: print 'switching to menu 2' return 'stuff2' return state class stuff2(object): def update(self,key,state): if 'SPACE release' in key: print 'switching to menu 3' return 'stuff3' return state class stuff3(object): def update(self,key,state): if 'SPACE release' in key: print 'switching to menu 1' return 'stuff1' return state if __name__ == '__main__': window = Test() pyglet.app.run()
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector