Mercurial > touhou
comparison pytouhou/games/eosd.py @ 321:61adb5453e46
Implement music playback.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 13 Jun 2012 15:29:43 +0200 |
parents | 8d1768fa4cbb |
children | 4e8192aadcaa |
comparison
equal
deleted
inserted
replaced
320:1a4ffdda8735 | 321:61adb5453e46 |
---|---|
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 | 24 from pytouhou.game.text import Text |
25 | 25 |
26 from os.path import join | |
27 from pytouhou.ui.music import InfiniteWaveSource | |
28 | |
26 | 29 |
27 SQ2 = 2. ** 0.5 / 2. | 30 SQ2 = 2. ** 0.5 / 2. |
28 | 31 |
29 | 32 |
30 class EoSDGame(Game): | 33 class EoSDGame(Game): |
31 def __init__(self, resource_loader, player_states, stage, rank, difficulty, | 34 def __init__(self, resource_loader, player_states, stage, rank, difficulty, |
32 bullet_types=None, laser_types=None, item_types=None, | 35 bullet_types=None, laser_types=None, item_types=None, |
33 nb_bullets_max=640, width=384, height=448, prng=None): | 36 nb_bullets_max=640, width=384, height=448, prng=None, bgms=None): |
34 | 37 |
35 if not bullet_types: | 38 if not bullet_types: |
36 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',)) | 39 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',)) |
37 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',)) | 40 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',)) |
38 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=4, | 41 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=4, |
91 characters = resource_loader.get_eosd_characters() | 94 characters = resource_loader.get_eosd_characters() |
92 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] | 95 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] |
93 | 96 |
94 interface = EoSDInterface(player_states, resource_loader) | 97 interface = EoSDInterface(player_states, resource_loader) |
95 | 98 |
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 | |
96 Game.__init__(self, resource_loader, players, stage, rank, difficulty, | 113 Game.__init__(self, resource_loader, players, stage, rank, difficulty, |
97 bullet_types, laser_types, item_types, nb_bullets_max, | 114 bullet_types, laser_types, item_types, nb_bullets_max, |
98 width, height, prng, interface) | 115 width, height, prng, interface) |
99 | 116 |
100 | 117 |