comparison pytouhou/games/eosd.py @ 341:61caded6b4f5

Clean music playback API a little.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 04 Jul 2012 23:05:21 +0200
parents 7a05edbab88a
children 2c4589370cc6
comparison
equal deleted inserted replaced
340:39bc59953dfa 341:61caded6b4f5
21 from pytouhou.game.player import Player 21 from pytouhou.game.player import Player
22 from pytouhou.game.orb import Orb 22 from pytouhou.game.orb import Orb
23 from pytouhou.game.effect import Effect 23 from pytouhou.game.effect import Effect
24 from pytouhou.game.text import Text, Counter 24 from pytouhou.game.text import Text, Counter
25 25
26 from os.path import join
27 from pytouhou.ui.music import InfiniteWaveSource
28
29 26
30 SQ2 = 2. ** 0.5 / 2. 27 SQ2 = 2. ** 0.5 / 2.
31 28
32 29
33 class EoSDGame(Game): 30 class EoSDGame(Game):
34 def __init__(self, resource_loader, player_states, stage, rank, difficulty, 31 def __init__(self, resource_loader, player_states, stage, rank, difficulty,
35 bullet_types=None, laser_types=None, item_types=None, 32 bullet_types=None, laser_types=None, item_types=None,
36 nb_bullets_max=640, width=384, height=448, prng=None, bgms=None, continues=0): 33 nb_bullets_max=640, width=384, height=448, prng=None, continues=0):
37 34
38 if not bullet_types: 35 if not bullet_types:
39 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',)) 36 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',))
40 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',)) 37 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',))
41 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=4, 38 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=4,
94 characters = resource_loader.get_eosd_characters() 91 characters = resource_loader.get_eosd_characters()
95 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] 92 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states]
96 93
97 interface = EoSDInterface(player_states, resource_loader) 94 interface = EoSDInterface(player_states, resource_loader)
98 95
99 self.bgms = []
100 for bgm in bgms:
101 if not bgm:
102 self.bgms.append(None)
103 continue
104 posname = bgm[1].replace('bgm/', '').replace('.mid', '.pos')
105 track = resource_loader.get_track(posname)
106 wavname = join(resource_loader.game_dir, bgm[1].replace('.mid', '.wav'))
107 try:
108 source = InfiniteWaveSource(wavname, track.start, track.end)
109 except IOError:
110 source = None
111 self.bgms.append(source)
112
113 Game.__init__(self, resource_loader, players, stage, rank, difficulty, 96 Game.__init__(self, resource_loader, players, stage, rank, difficulty,
114 bullet_types, laser_types, item_types, nb_bullets_max, 97 bullet_types, laser_types, item_types, nb_bullets_max,
115 width, height, prng, interface, continues) 98 width, height, prng, interface, continues)
116 99
117 100