comparison pytouhou/games/eosd.py @ 428:f41a26971a19

Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:17:22 +0200
parents 608468be7a93
children c9433188ffdb
comparison
equal deleted inserted replaced
427:0604f4fbbe3c 428:f41a26971a19
20 from pytouhou.game.itemtype import ItemType 20 from pytouhou.game.itemtype import ItemType
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, Gauge 24 from pytouhou.game.text import Text, Counter, Gauge
25 25 from pytouhou.game.background import Background
26 26
27 SQ2 = 2. ** 0.5 / 2. 27 from pytouhou.vm.eclrunner import ECLMainRunner
28 28
29 29
30 class EoSDGame(Game): 30 class EoSDGame(Game):
31 def __init__(self, resource_loader, player_states, stage, rank, difficulty, 31 def __init__(self, resource_loader, player_states, stage, rank, difficulty,
32 bullet_types=None, laser_types=None, item_types=None, 32 bullet_types=None, laser_types=None, item_types=None,
33 nb_bullets_max=640, width=384, height=448, prng=None, 33 nb_bullets_max=640, width=384, height=448, prng=None,
34 continues=0, hints=None): 34 continues=0, hints=None):
35 35
36 if not bullet_types: 36 if not bullet_types:
37 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',)) 37 etama3 = resource_loader.get_anm_wrapper(('etama3.anm',))
38 etama4 = resource_loader.get_anm_wrapper(('etama4.anm',)) 38 self.etama = resource_loader.get_anm_wrapper(('etama4.anm',))
39 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=2, 39 bullet_types = [BulletType(etama3, 0, 11, 14, 15, 16, hitbox_size=2,
40 type_id=0), 40 type_id=0),
41 BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=3, 41 BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=3,
42 type_id=1), 42 type_id=1),
43 BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=2, 43 BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=2,
55 launch_anim_offsets=(1,)*28, 55 launch_anim_offsets=(1,)*28,
56 type_id=7), 56 type_id=7),
57 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=4.5, 57 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=4.5,
58 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), 58 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0),
59 type_id=8), 59 type_id=8),
60 BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=16, 60 BulletType(self.etama, 0, 1, 2, 2, 2, hitbox_size=16,
61 launch_anim_offsets=(0, 1, 2, 3, 4, 5, 6, 7, 8), 61 launch_anim_offsets=(0, 1, 2, 3, 4, 5, 6, 7, 8),
62 type_id=9)] 62 type_id=9)]
63 63
64 if not laser_types: 64 if not laser_types:
65 laser_types = [LaserType(etama3, 9), 65 laser_types = [LaserType(etama3, 9),
71 ItemType(etama3, 2, 9), #Big power 71 ItemType(etama3, 2, 9), #Big power
72 ItemType(etama3, 3, 10), #Bomb 72 ItemType(etama3, 3, 10), #Bomb
73 ItemType(etama3, 4, 11), #Full power 73 ItemType(etama3, 4, 11), #Full power
74 ItemType(etama3, 5, 12), #1up 74 ItemType(etama3, 5, 12), #1up
75 ItemType(etama3, 6, 13)] #Star 75 ItemType(etama3, 6, 13)] #Star
76
77 self.enm_anm_wrapper = resource_loader.get_anm_wrapper2(('stg%denm.anm' % stage,
78 'stg%denm2.anm' % stage))
79 ecl = resource_loader.get_ecl('ecldata%d.ecl' % stage)
80 self.ecl_runners = [ECLMainRunner(main, ecl.subs, self) for main in ecl.mains]
81
82 self.spellcard_effect_anm_wrapper = resource_loader.get_anm_wrapper(('eff0%d.anm' % stage,))
76 83
77 player_face = player_states[0].character // 2 84 player_face = player_states[0].character // 2
78 enemy_face = [('face03a.anm', 'face03b.anm'), 85 enemy_face = [('face03a.anm', 'face03b.anm'),
79 ('face05a.anm',), 86 ('face05a.anm',),
80 ('face06a.anm', 'face06b.anm'), 87 ('face06a.anm', 'face06b.anm'),
93 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] 100 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states]
94 101
95 self.stage = stage #XXX 102 self.stage = stage #XXX
96 interface = EoSDInterface(self, resource_loader) 103 interface = EoSDInterface(self, resource_loader)
97 104
98 Game.__init__(self, resource_loader, players, stage, rank, difficulty, 105 # Load stage data
106 self.std = resource_loader.get_stage('stage%d.std' % stage)
107
108 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage,))
109 self.background = Background(self.std, background_anm_wrapper)
110
111 self.resource_loader = resource_loader #XXX: currently used for texture preload in pytouhou.ui.gamerunner. Wipe it!
112
113 Game.__init__(self, players, stage, rank, difficulty,
99 bullet_types, laser_types, item_types, nb_bullets_max, 114 bullet_types, laser_types, item_types, nb_bullets_max,
100 width, height, prng, interface, continues, hints) 115 width, height, prng, interface, continues, hints)
101 116
102 117
103 118
275 self.orbs[0].offset_y = dy 290 self.orbs[0].offset_y = dy
276 self.orbs[1].offset_y = dy 291 self.orbs[1].offset_y = dy
277 292
278 for orb in self.orbs: 293 for orb in self.orbs:
279 orb.update() 294 orb.update()
280