Re: pyglet question
Actually, digging abit into Pyglets documentation I think i've come up with a better example thats alot closer to the pygame version. Instead of having to use event tags or window subclassing you can also push keyboard handling into the windows event stack and handle it similarly to pygame.
import pyglet
from pyglet.window import key
def Example():
#create window
window = pyglet.window.Window(640,480,caption='Example')
#load sound
sound = pyglet.media.load('example.wav',streaming=False)
#load image
picture = pyglet.image.load('example.png')
#load keyboard handler
keyboard = key.KeyStateHandler()
#add keyboard handler to window
window.push_handlers(keyboard)
#main update loop while True: if keyboard.items(): #play sound if keyboard.get(key.SPACE): sound.play() #quit program if keyboard.get(key.ESCAPE): window.close() #clear keyboard buffer keyboard.clear() #clear screen window.clear() #draw picture to window picture.blit(0,0) #update screen window.flip() #dispatch events window.dispatch_events() Example()
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector