Mercurial > touhou
comparison pytouhou/games/eosd.py @ 430:c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 03 Aug 2013 15:49:04 +0200 |
parents | f41a26971a19 |
children | 18e4b121646b |
comparison
equal
deleted
inserted
replaced
429:40d5f3083ebc | 430:c9433188ffdb |
---|---|
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 self.etama = resource_loader.get_multi_anm(('etama3.anm', 'etama4.anm')) |
38 self.etama = resource_loader.get_anm_wrapper(('etama4.anm',)) | 38 bullet_types = [BulletType(self.etama[0], 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), | 39 type_id=0), |
41 BulletType(etama3, 1, 12, 17, 18, 19, hitbox_size=3, | 40 BulletType(self.etama[0], 1, 12, 17, 18, 19, hitbox_size=3, |
42 type_id=1), | 41 type_id=1), |
43 BulletType(etama3, 2, 12, 17, 18, 19, hitbox_size=2, | 42 BulletType(self.etama[0], 2, 12, 17, 18, 19, hitbox_size=2, |
44 type_id=2), | 43 type_id=2), |
45 BulletType(etama3, 3, 12, 17, 18, 19, hitbox_size=3, | 44 BulletType(self.etama[0], 3, 12, 17, 18, 19, hitbox_size=3, |
46 type_id=3), | 45 type_id=3), |
47 BulletType(etama3, 4, 12, 17, 18, 19, hitbox_size=2.5, | 46 BulletType(self.etama[0], 4, 12, 17, 18, 19, hitbox_size=2.5, |
48 type_id=4), | 47 type_id=4), |
49 BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=2, | 48 BulletType(self.etama[0], 5, 12, 17, 18, 19, hitbox_size=2, |
50 type_id=5), | 49 type_id=5), |
51 BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=8, | 50 BulletType(self.etama[0], 6, 13, 20, 20, 20, hitbox_size=8, |
52 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), | 51 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), |
53 type_id=6), | 52 type_id=6), |
54 BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=5.5, | 53 BulletType(self.etama[0], 7, 13, 20, 20, 20, hitbox_size=5.5, |
55 launch_anim_offsets=(1,)*28, | 54 launch_anim_offsets=(1,)*28, |
56 type_id=7), | 55 type_id=7), |
57 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=4.5, | 56 BulletType(self.etama[0], 8, 13, 20, 20, 20, hitbox_size=4.5, |
58 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), | 57 launch_anim_offsets=(0, 1, 1, 2, 2, 3, 4, 0), |
59 type_id=8), | 58 type_id=8), |
60 BulletType(self.etama, 0, 1, 2, 2, 2, hitbox_size=16, | 59 BulletType(self.etama[1], 0, 1, 2, 2, 2, hitbox_size=16, |
61 launch_anim_offsets=(0, 1, 2, 3, 4, 5, 6, 7, 8), | 60 launch_anim_offsets=(0, 1, 2, 3, 4, 5, 6, 7, 8), |
62 type_id=9)] | 61 type_id=9)] |
63 | 62 |
64 if not laser_types: | 63 if not laser_types: |
65 laser_types = [LaserType(etama3, 9), | 64 laser_types = [LaserType(self.etama[0], 9), |
66 LaserType(etama3, 10)] | 65 LaserType(self.etama[0], 10)] |
67 | 66 |
68 if not item_types: | 67 if not item_types: |
69 item_types = [ItemType(etama3, 0, 7), #Power | 68 item_types = [ItemType(self.etama[0], 0, 7), #Power |
70 ItemType(etama3, 1, 8), #Point | 69 ItemType(self.etama[0], 1, 8), #Point |
71 ItemType(etama3, 2, 9), #Big power | 70 ItemType(self.etama[0], 2, 9), #Big power |
72 ItemType(etama3, 3, 10), #Bomb | 71 ItemType(self.etama[0], 3, 10), #Bomb |
73 ItemType(etama3, 4, 11), #Full power | 72 ItemType(self.etama[0], 4, 11), #Full power |
74 ItemType(etama3, 5, 12), #1up | 73 ItemType(self.etama[0], 5, 12), #1up |
75 ItemType(etama3, 6, 13)] #Star | 74 ItemType(self.etama[0], 6, 13)] #Star |
76 | 75 |
77 self.enm_anm_wrapper = resource_loader.get_anm_wrapper2(('stg%denm.anm' % stage, | 76 try: |
78 'stg%denm2.anm' % stage)) | 77 self.enm_anm = resource_loader.get_multi_anm(('stg%denm.anm' % stage, |
78 'stg%denm2.anm' % stage)) | |
79 except KeyError: | |
80 self.enm_anm = resource_loader.get_anm('stg%denm.anm' % stage) | |
79 ecl = resource_loader.get_ecl('ecldata%d.ecl' % stage) | 81 ecl = resource_loader.get_ecl('ecldata%d.ecl' % stage) |
80 self.ecl_runners = [ECLMainRunner(main, ecl.subs, self) for main in ecl.mains] | 82 self.ecl_runners = [ECLMainRunner(main, ecl.subs, self) for main in ecl.mains] |
81 | 83 |
82 self.spellcard_effect_anm_wrapper = resource_loader.get_anm_wrapper(('eff0%d.anm' % stage,)) | 84 self.spellcard_effect_anm = resource_loader.get_single_anm('eff0%d.anm' % stage) |
83 | 85 |
84 player_face = player_states[0].character // 2 | 86 player_face = player_states[0].character // 2 |
85 enemy_face = [('face03a.anm', 'face03b.anm'), | 87 enemy_face = [('face03a.anm', 'face03b.anm'), |
86 ('face05a.anm',), | 88 ('face05a.anm',), |
87 ('face06a.anm', 'face06b.anm'), | 89 ('face06a.anm', 'face06b.anm'), |
88 ('face08a.anm', 'face08b.anm'), | 90 ('face08a.anm', 'face08b.anm'), |
89 ('face09a.anm', 'face09b.anm'), | 91 ('face09a.anm', 'face09b.anm'), |
90 ('face09b.anm', 'face10a.anm', 'face10b.anm'), | 92 ('face09b.anm', 'face10a.anm', 'face10b.anm'), |
91 ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')] | 93 ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')] |
92 self.msg = resource_loader.get_msg('msg%d.dat' % stage) | 94 self.msg = resource_loader.get_msg('msg%d.dat' % stage) |
93 self.msg_anm_wrapper = resource_loader.get_anm_wrapper2(('face0%da.anm' % player_face, | 95 msg_anm = [resource_loader.get_multi_anm(('face0%da.anm' % player_face, |
94 'face0%db.anm' % player_face, | 96 'face0%db.anm' % player_face, |
95 'face0%dc.anm' % player_face) | 97 'face0%dc.anm' % player_face)), |
96 + enemy_face[stage - 1], | 98 resource_loader.get_multi_anm(enemy_face[stage - 1])] |
97 (0, 2, 4, 8, 10, 11, 12)) | 99 |
100 self.msg_anm = [[], []] | |
101 for i, anms in enumerate(msg_anm): | |
102 for anm in anms: | |
103 for sprite in anm.sprites.values(): | |
104 self.msg_anm[i].append((anm, sprite)) | |
98 | 105 |
99 characters = resource_loader.get_eosd_characters() | 106 characters = resource_loader.get_eosd_characters() |
100 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] | 107 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] |
101 | 108 |
102 self.stage = stage #XXX | 109 self.stage = stage #XXX |
103 interface = EoSDInterface(self, resource_loader) | 110 interface = EoSDInterface(self, resource_loader) |
104 | 111 |
105 # Load stage data | 112 # Load stage data |
106 self.std = resource_loader.get_stage('stage%d.std' % stage) | 113 self.std = resource_loader.get_stage('stage%d.std' % stage) |
107 | 114 |
108 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage,)) | 115 background_anm = resource_loader.get_single_anm('stg%dbg.anm' % stage) |
109 self.background = Background(self.std, background_anm_wrapper) | 116 self.background = Background(self.std, background_anm) |
110 | 117 |
111 self.resource_loader = resource_loader #XXX: currently used for texture preload in pytouhou.ui.gamerunner. Wipe it! | 118 self.resource_loader = resource_loader #XXX: currently used for texture preload in pytouhou.ui.gamerunner. Wipe it! |
112 | 119 |
113 Game.__init__(self, players, stage, rank, difficulty, | 120 Game.__init__(self, players, stage, rank, difficulty, |
114 bullet_types, laser_types, item_types, nb_bullets_max, | 121 bullet_types, laser_types, item_types, nb_bullets_max, |
117 | 124 |
118 | 125 |
119 class EoSDInterface(object): | 126 class EoSDInterface(object): |
120 def __init__(self, game, resource_loader): | 127 def __init__(self, game, resource_loader): |
121 self.game = game | 128 self.game = game |
122 front = resource_loader.get_anm_wrapper(('front.anm',)) | 129 front = resource_loader.get_single_anm('front.anm') |
123 self.ascii_wrapper = resource_loader.get_anm_wrapper(('ascii.anm',)) | 130 self.ascii_anm = resource_loader.get_single_anm('ascii.anm') |
124 | 131 |
125 self.width = 640 | 132 self.width = 640 |
126 self.height = 480 | 133 self.height = 480 |
127 self.game_pos = (32, 16) | 134 self.game_pos = (32, 16) |
128 | 135 |
134 [Effect((0, 0), 5, front)] + | 141 [Effect((0, 0), 5, front)] + |
135 [Effect((0, 0), i, front) for i in range(5) + range(9, 16)]) | 142 [Effect((0, 0), i, front) for i in range(5) + range(9, 16)]) |
136 for item in self.items: | 143 for item in self.items: |
137 item.sprite.allow_dest_offset = True #XXX | 144 item.sprite.allow_dest_offset = True #XXX |
138 | 145 |
139 self.level_start = [Text((176, 200), self.ascii_wrapper, text='STAGE %d' % game.stage)] #TODO: find the exact location. | 146 self.level_start = [Text((176, 200), self.ascii_anm, text='STAGE %d' % game.stage)] #TODO: find the exact location. |
140 self.level_start[0].set_timeout(240, effect='fadeout', duration=60, start=120) | 147 self.level_start[0].set_timeout(240, effect='fadeout', duration=60, start=120) |
141 self.level_start[0].set_color('yellow') | 148 self.level_start[0].set_color('yellow') |
142 #TODO: use the system text for the stage name, and the song name. | 149 #TODO: use the system text for the stage name, and the song name. |
143 | 150 |
144 self.labels = { | 151 self.labels = { |
145 'highscore': Text((500, 58), self.ascii_wrapper, front, text='0'), | 152 'highscore': Text((500, 58), self.ascii_anm, front, text='0'), |
146 'score': Text((500, 82), self.ascii_wrapper, front, text='0'), | 153 'score': Text((500, 82), self.ascii_anm, front, text='0'), |
147 'player': Counter((500, 122), front, front, script=16, value=0), | 154 'player': Counter((500, 122), front, front, script=16, value=0), |
148 'bombs': Counter((500, 146), front, front, script=17, value=0), | 155 'bombs': Counter((500, 146), front, front, script=17, value=0), |
149 'power': Text((500, 186), self.ascii_wrapper, front, text='0'), | 156 'power': Text((500, 186), self.ascii_anm, front, text='0'), |
150 'graze': Text((500, 206), self.ascii_wrapper, front, text='0'), | 157 'graze': Text((500, 206), self.ascii_anm, front, text='0'), |
151 'points': Text((500, 226), self.ascii_wrapper, front, text='0'), | 158 'points': Text((500, 226), self.ascii_anm, front, text='0'), |
152 'framerate': Text((512, 464), self.ascii_wrapper, front), | 159 'framerate': Text((512, 464), self.ascii_anm, front), |
153 'debug?': Text((0, 464), self.ascii_wrapper, front), | 160 'debug?': Text((0, 464), self.ascii_anm, front), |
154 | 161 |
155 # Only when there is a boss. | 162 # Only when there is a boss. |
156 'boss_lives': Text((80, 16), self.ascii_wrapper), | 163 'boss_lives': Text((80, 16), self.ascii_anm), |
157 'timeout': Text((384, 16), self.ascii_wrapper), | 164 'timeout': Text((384, 16), self.ascii_anm), |
158 } | 165 } |
159 self.labels['boss_lives'].set_color('yellow') | 166 self.labels['boss_lives'].set_color('yellow') |
160 | 167 |
161 self.boss_items = [ | 168 self.boss_items = [ |
162 Effect((0, 0), 19, front), # Enemy | 169 Effect((0, 0), 19, front), # Enemy |
235 | 242 |
236 class EoSDPlayer(Player): | 243 class EoSDPlayer(Player): |
237 def __init__(self, state, game, resource_loader, character): | 244 def __init__(self, state, game, resource_loader, character): |
238 self.sht = character[0] | 245 self.sht = character[0] |
239 self.focused_sht = character[1] | 246 self.focused_sht = character[1] |
240 anm_wrapper = resource_loader.get_anm_wrapper(('player0%d.anm' % (state.character // 2),)) | 247 self.anm = resource_loader.get_single_anm('player0%d.anm' % (state.character // 2)) |
241 self.anm_wrapper = anm_wrapper | 248 |
242 | 249 Player.__init__(self, state, game, self.anm) |
243 Player.__init__(self, state, game, anm_wrapper) | 250 |
244 | 251 self.orbs = [Orb(self.anm, 128, self.state, None), |
245 self.orbs = [Orb(self.anm_wrapper, 128, self.state, None), | 252 Orb(self.anm, 129, self.state, None)] |
246 Orb(self.anm_wrapper, 129, self.state, None)] | |
247 | 253 |
248 self.orbs[0].offset_x = -24 | 254 self.orbs[0].offset_x = -24 |
249 self.orbs[1].offset_x = 24 | 255 self.orbs[1].offset_x = 24 |
250 | 256 |
251 self.orb_dx_interpolator = None | 257 self.orb_dx_interpolator = None |