comparison pytouhou/ui/gamerunner.py @ 321:61adb5453e46

Implement music playback.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 13 Jun 2012 15:29:43 +0200
parents f3099ebf4f61
children 2fcdb8966957
comparison
equal deleted inserted replaced
320:1a4ffdda8735 321:61adb5453e46
22 GL_MODELVIEW, GL_PROJECTION, 22 GL_MODELVIEW, GL_PROJECTION,
23 GL_TEXTURE_2D, GL_BLEND, GL_FOG, 23 GL_TEXTURE_2D, GL_BLEND, GL_FOG,
24 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, 24 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST,
25 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY, 25 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY,
26 GL_SCISSOR_TEST) 26 GL_SCISSOR_TEST)
27
28 from pyglet.media import Player as MusicPlayer
27 29
28 from pytouhou.utils.helpers import get_logger 30 from pytouhou.utils.helpers import get_logger
29 31
30 from .gamerenderer import GameRenderer 32 from .gamerenderer import GameRenderer
31 33
69 glHint(GL_FOG_HINT, GL_NICEST) 71 glHint(GL_FOG_HINT, GL_NICEST)
70 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) 72 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
71 glEnableClientState(GL_COLOR_ARRAY) 73 glEnableClientState(GL_COLOR_ARRAY)
72 glEnableClientState(GL_VERTEX_ARRAY) 74 glEnableClientState(GL_VERTEX_ARRAY)
73 glEnableClientState(GL_TEXTURE_COORD_ARRAY) 75 glEnableClientState(GL_TEXTURE_COORD_ARRAY)
76
77 # Initialize sound
78 self.game.music = MusicPlayer()
79 bgm = self.game.bgms[0]
80 if bgm:
81 self.game.music.queue(bgm)
82 self.game.music.play()
74 83
75 # Use our own loop to ensure 60 (for now, 120) fps 84 # Use our own loop to ensure 60 (for now, 120) fps
76 pyglet.clock.set_fps_limit(120) 85 pyglet.clock.set_fps_limit(120)
77 while not self.has_exit: 86 while not self.has_exit:
78 pyglet.clock.tick() 87 pyglet.clock.tick()