Mercurial > touhou
comparison pytouhou/games/eosd.py @ 235:e59bd7979ddc
Do a little cleanup, and fix PCB SHT usage.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 31 Dec 2011 16:31:10 +0100 |
parents | 067f6d9c562b |
children | 8fa660da5f0c |
comparison
equal
deleted
inserted
replaced
234:3cbfa2c11dec | 235:e59bd7979ddc |
---|---|
16 | 16 |
17 from pytouhou.game.game import Game | 17 from pytouhou.game.game import Game |
18 from pytouhou.game.bullettype import BulletType | 18 from pytouhou.game.bullettype import BulletType |
19 from pytouhou.game.itemtype import ItemType | 19 from pytouhou.game.itemtype import ItemType |
20 from pytouhou.game.player import Player | 20 from pytouhou.game.player import Player |
21 from pytouhou.game.bullet import Bullet | |
22 from pytouhou.game.orb import Orb | 21 from pytouhou.game.orb import Orb |
23 | 22 |
24 from math import pi | 23 from math import pi |
25 | 24 |
26 | 25 |
39 BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=4), | 38 BulletType(etama3, 5, 12, 17, 18, 19, hitbox_size=4), |
40 BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=16), | 39 BulletType(etama3, 6, 13, 20, 20, 20, hitbox_size=16), |
41 BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=11), | 40 BulletType(etama3, 7, 13, 20, 20, 20, hitbox_size=11), |
42 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=9), | 41 BulletType(etama3, 8, 13, 20, 20, 20, hitbox_size=9), |
43 BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=32)] | 42 BulletType(etama4, 0, 1, 2, 2, 2, hitbox_size=32)] |
44 #TODO: hitbox | 43 |
45 item_types = [ItemType(etama3, 0, 7), #Power | 44 item_types = [ItemType(etama3, 0, 7), #Power |
46 ItemType(etama3, 1, 8), #Point | 45 ItemType(etama3, 1, 8), #Point |
47 ItemType(etama3, 2, 9), #Big power | 46 ItemType(etama3, 2, 9), #Big power |
48 ItemType(etama3, 3, 10), #Bomb | 47 ItemType(etama3, 3, 10), #Bomb |
49 ItemType(etama3, 4, 11), #Full power | 48 ItemType(etama3, 4, 11), #Full power |
50 ItemType(etama3, 5, 12), #1up | 49 ItemType(etama3, 5, 12), #1up |
51 ItemType(etama3, 6, 13)] #Star | 50 ItemType(etama3, 6, 13)] #Star |
52 | 51 |
53 characters = resource_loader.get_eosd_characters('102h.exe') | 52 characters = resource_loader.get_eosd_characters('102h.exe') |
54 | 53 players = [EoSDPlayer(state, self, resource_loader, characters[state.character]) for state in player_states] |
55 players = [] | |
56 for player in player_states: | |
57 players.append(EoSDPlayer(player, self, resource_loader, sht=characters[player.character])) | |
58 | 54 |
59 Game.__init__(self, resource_loader, players, stage, rank, difficulty, | 55 Game.__init__(self, resource_loader, players, stage, rank, difficulty, |
60 bullet_types, item_types, nb_bullets_max=640, **kwargs) | 56 bullet_types, item_types, nb_bullets_max=640, **kwargs) |
61 | 57 |
62 | 58 |
63 | 59 |
64 class EoSDPlayer(Player): | 60 class EoSDPlayer(Player): |
65 def __init__(self, state, game, resource_loader, speeds=None, hitbox_size=2.5, graze_hitbox_size=42., sht=None): | 61 def __init__(self, state, game, resource_loader, character): |
66 self.sht = sht | 62 self.sht = character[0] |
63 self.focused_sht = character[1] | |
67 anm_wrapper = resource_loader.get_anm_wrapper(('player0%d.anm' % (state.character // 2),)) | 64 anm_wrapper = resource_loader.get_anm_wrapper(('player0%d.anm' % (state.character // 2),)) |
68 self.anm_wrapper = anm_wrapper | 65 self.anm_wrapper = anm_wrapper |
69 | 66 |
70 Player.__init__(self, state, game, anm_wrapper, | 67 Player.__init__(self, state, game, anm_wrapper) |
71 speeds=(self.sht.horizontal_vertical_speed, | |
72 self.sht.diagonal_speed, | |
73 self.sht.horizontal_vertical_focused_speed, | |
74 self.sht.diagonal_focused_speed)) | |
75 | 68 |
76 self.orbs = [Orb(self.anm_wrapper, 128, self.state, None), | 69 self.orbs = [Orb(self.anm_wrapper, 128, self.state, None), |
77 Orb(self.anm_wrapper, 129, self.state, None)] | 70 Orb(self.anm_wrapper, 129, self.state, None)] |
78 | 71 |
79 self.orbs[0].offset_x = -24 | 72 self.orbs[0].offset_x = -24 |
121 self.orbs[1].offset_y = dy | 114 self.orbs[1].offset_y = dy |
122 | 115 |
123 for orb in self.orbs: | 116 for orb in self.orbs: |
124 orb.update() | 117 orb.update() |
125 | 118 |
126 | |
127 def fire(self): | |
128 sht = self.sht | |
129 power = min(power for power in sht.shots if self.state.power < power) | |
130 | |
131 bullets = self._game.players_bullets | |
132 nb_bullets_max = self._game.nb_bullets_max | |
133 | |
134 for shot in sht.shots[power]: | |
135 if shot.type == 3: # TODO: Lasers aren't implemented yet | |
136 continue | |
137 | |
138 if self.fire_time % shot.interval != shot.delay: | |
139 continue | |
140 | |
141 if nb_bullets_max is not None and len(bullets) == nb_bullets_max: | |
142 break | |
143 | |
144 origin = self.orbs[shot.orb - 1] if shot.orb else self | |
145 x = origin.x + shot.pos[0] | |
146 y = origin.y + shot.pos[1] | |
147 | |
148 #TODO: find a better way to do that. | |
149 bullet_type = BulletType(self.anm_wrapper, shot.sprite % 256, | |
150 shot.sprite % 256 + 32, #TODO: find the real cancel anim | |
151 0, 0, 0, 0.) | |
152 if shot.type == 2: | |
153 #TODO: triple-check acceleration! | |
154 bullets.append(Bullet((x, y), bullet_type, 0, | |
155 shot.angle, shot.speed, | |
156 (-1, 0, 0, 0, 0.15, -pi/2., 0., 0.), | |
157 16, self, self._game, player_bullet=True, | |
158 damage=shot.damage, hitbox=shot.hitbox)) | |
159 #TODO: types 1 and 4 | |
160 else: | |
161 bullets.append(Bullet((x, y), bullet_type, 0, | |
162 shot.angle, shot.speed, | |
163 (0, 0, 0, 0, 0., 0., 0., 0.), | |
164 0, self, self._game, player_bullet=True, | |
165 damage=shot.damage, hitbox=shot.hitbox)) | |
166 |