Changeset 247
- Timestamp:
- 01/05/07 03:57:30 (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 modified
-
setup.py (modified) (1 diff)
-
src/pyspacewar/music (added)
-
src/pyspacewar/music/README.txt (added)
-
src/pyspacewar/ui.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/setup.py
r237 r247 50 50 packages=['pyspacewar'], 51 51 package_dir={'pyspacewar': 'src/pyspacewar'}, 52 package_data={'pyspacewar': ['images/*', 'sounds/*' ]},52 package_data={'pyspacewar': ['images/*', 'sounds/*', 'music/*']}, 53 53 ) -
trunk/src/pyspacewar/ui.py
r246 r247 1092 1092 mouse_visible = False 1093 1093 keys_repeat = False 1094 music = None 1094 1095 1095 1096 inherit_pause_from_prev_mode = False … … 1117 1118 else: 1118 1119 pygame.key.set_repeat() 1120 if self.music: 1121 self.ui.play_music(self.music) 1119 1122 1120 1123 def leave(self, next_mode=None): … … 1237 1240 1238 1241 paused = False 1242 music = 'demo' 1239 1243 1240 1244 def init(self): … … 1600 1604 1601 1605 paused = False 1606 music = 'game' 1602 1607 1603 1608 def init(self): … … 1639 1644 1640 1645 paused = False 1646 music = 'gravitywars' 1641 1647 1642 1648 def init(self): … … 1780 1786 1781 1787 _ui_mode = None # Previous user interface mode 1788 1789 now_playing = None # Filename of the current music track 1782 1790 1783 1791 # Some debug information … … 1854 1862 self._init_trail_colors() 1855 1863 self._load_sounds() 1864 self._load_music() 1856 1865 self._load_planet_images() 1857 1866 self._load_background() … … 1983 1992 self.respawn_sound = pygame.mixer.Sound(find('sounds', 'coin2.wav')) 1984 1993 self.menu_sound = pygame.mixer.Sound(find('sounds', 'briefcs1.wav')) 1994 1995 def _load_music(self): 1996 """Load music files.""" 1997 self.music_files = { 1998 'demo': find('music', 'demo.ogg'), 1999 'game': find('music', 'game.ogg'), 2000 'gravitywars': find('music', 'gravitywars.ogg'), 2001 } 2002 2003 def play_music(self, which): 2004 """Loop the music file for a certain mode.""" 2005 if which == self.now_playing: 2006 return 2007 filename = self.music_files.get(which) 2008 if not filename: 2009 pygame.mixer.music.stop() 2010 else: 2011 try: 2012 pygame.mixer.music.load(filename) 2013 pygame.mixer.music.play(-1) 2014 except pygame.error: 2015 # Don't print warnings while I don't have any music actually 2016 # bundled with pyspacewar 2017 # print "pyspacewar: could not load %s" % filename 2018 pygame.mixer.music.stop() 2019 self.now_playing = which 1985 2020 1986 2021 def _init_fonts(self):
