Re: Python or PureBasic
The [ a-t ] sign is part of how you set event handlers in Pyglet as discussed here in the documentation, though I rarely write code this way. For reference, here is another example not using such event handlers by sub-classing pyglets window class.
import pyglet
#sub class of window
class Example(pyglet.window.Window):
def __init__(self):
#have window sub-class call itself to set parameters
super(Example, self).__init__(640, 480, resizable=False, fullscreen=False, caption="Test")
#have pyglet repeatedly call our update function every 0.2 seconds pyglet.clock.schedule_interval(self.update, .02) #main update loop def update(self,dt): self.draw() #draw screen def draw(self): self.clear() #capture key presses def on_key_press(self,symbol,modifiers): if symbol == pyglet.window.key.SPACE: print 'space pressed' #press escape to close program elif symbol == pyglet.window.key.ESCAPE: self.close() #capture key releases def on_key_release(self,symbol,modifiers): if symbol == pyglet.window.key.SPACE: print 'space released' #load custom window class window = Example() pyglet.app.run()
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector