Changeset 242 for trunk/src/pyspacewar/ui.py
- Timestamp:
- 01/05/07 03:18:50 (5 years ago)
- Files:
-
- 1 modified
-
trunk/src/pyspacewar/ui.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/pyspacewar/ui.py
r241 r242 1971 1971 def _load_sounds(self): 1972 1972 """Load bitmaps of planets.""" 1973 self.thruster_sound_playing = False 1974 self.thruster_sound = pygame.mixer.Sound(find('sounds', 1975 'Pink_Noise1.wav')) 1976 self.thruster_sound.set_volume(0.5) 1973 1977 self.fire_sound = pygame.mixer.Sound(find('sounds', 1974 1978 'Gun_Silencer.wav')) … … 2118 2122 pressed = pygame.key.get_pressed() 2119 2123 self.ui_mode.handle_held_keys(pressed) 2124 self.update_continuous_sounds() 2120 2125 2121 2126 def quit(self): … … 2290 2295 if not self.ai_controlled[player_id]: 2291 2296 self.respawn_sound.play() 2297 2298 def update_continuous_sounds(self): 2299 """Loop certain sound effects while certain conditions hold true.""" 2300 makes_noise = False 2301 for player_id, ship in enumerate(self.ships): 2302 if not self.ai_controlled[player_id]: 2303 makes_noise = (ship.forward_thrust or ship.rear_thrust or 2304 ship.left_thrust or ship.right_thrust or 2305 ship.engage_brakes) or makes_noise 2306 if self.thruster_sound_playing and not makes_noise: 2307 self.thruster_sound.stop() 2308 elif not self.thruster_sound_playing and makes_noise: 2309 self.thruster_sound.play(-1) 2310 self.thruster_sound_playing = makes_noise 2292 2311 2293 2312 def draw(self):
