Mercurial > touhou
comparison pytouhou/game/player.py @ 304:f3099ebf4f61
Update attribute names to reflect the actual interface.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 13 Mar 2012 18:38:14 +0100 |
parents | 647bde10353d |
children | 56523a16db1d |
comparison
equal
deleted
inserted
replaced
303:647bde10353d | 304:f3099ebf4f61 |
---|---|
46 self.power_bonus = 0 # Never goes over 30. | 46 self.power_bonus = 0 # Never goes over 30. |
47 | 47 |
48 | 48 |
49 class Player(object): | 49 class Player(object): |
50 def __init__(self, state, game, anm_wrapper): | 50 def __init__(self, state, game, anm_wrapper): |
51 self._sprite = None | |
52 self._anmrunner = None | |
53 self._game = game | 51 self._game = game |
52 self.sprite = None | |
53 self.anmrunner = None | |
54 self.anm_wrapper = anm_wrapper | 54 self.anm_wrapper = anm_wrapper |
55 | 55 |
56 self.speeds = (self.sht.horizontal_vertical_speed, | 56 self.speeds = (self.sht.horizontal_vertical_speed, |
57 self.sht.diagonal_speed, | 57 self.sht.diagonal_speed, |
58 self.sht.horizontal_vertical_focused_speed, | 58 self.sht.horizontal_vertical_focused_speed, |
84 def objects(self): | 84 def objects(self): |
85 return [] | 85 return [] |
86 | 86 |
87 | 87 |
88 def set_anim(self, index): | 88 def set_anim(self, index): |
89 self._sprite = Sprite() | 89 self.sprite = Sprite() |
90 self._anmrunner = ANMRunner(self.anm_wrapper, index, self._sprite) | 90 self.anmrunner = ANMRunner(self.anm_wrapper, index, self.sprite) |
91 self._anmrunner.run_frame() | 91 self.anmrunner.run_frame() |
92 | 92 |
93 | 93 |
94 def collide(self): | 94 def collide(self): |
95 if not self.state.invulnerable_time and not self.death_time and self.state.touchable: # Border Between Life and Death | 95 if not self.state.invulnerable_time and not self.death_time and self.state.touchable: # Border Between Life and Death |
96 self.death_time = self._game.frame | 96 self.death_time = self._game.frame |
191 if self.state.invulnerable_time > 0: | 191 if self.state.invulnerable_time > 0: |
192 self.state.invulnerable_time -= 1 | 192 self.state.invulnerable_time -= 1 |
193 | 193 |
194 m = self.state.invulnerable_time % 8 | 194 m = self.state.invulnerable_time % 8 |
195 if m == 0: | 195 if m == 0: |
196 self._sprite.color = (255, 255, 255) | 196 self.sprite.color = (255, 255, 255) |
197 self._sprite._changed = True | 197 self.sprite.changed = True |
198 elif m == 2: | 198 elif m == 2: |
199 self._sprite.color = (64, 64, 64) | 199 self.sprite.color = (64, 64, 64) |
200 self._sprite._changed = True | 200 self.sprite.changed = True |
201 | 201 |
202 if keystate & 1 and self.fire_time == 0: | 202 if keystate & 1 and self.fire_time == 0: |
203 self.fire_time = 30 | 203 self.fire_time = 30 |
204 if self.fire_time > 0: | 204 if self.fire_time > 0: |
205 self.fire() | 205 self.fire() |
222 self._game.drop_bonus(self.state.x, self.state.y, 0, | 222 self._game.drop_bonus(self.state.x, self.state.y, 0, |
223 end_pos=(self._game.prng.rand_double() * 288 + 48, | 223 end_pos=(self._game.prng.rand_double() * 288 + 48, |
224 self._game.prng.rand_double() * 192 - 64)) | 224 self._game.prng.rand_double() * 192 - 64)) |
225 | 225 |
226 elif time == 7: | 226 elif time == 7: |
227 self._sprite.mirrored = False | 227 self.sprite.mirrored = False |
228 self._sprite.blendfunc = 0 | 228 self.sprite.blendfunc = 0 |
229 self._sprite.rescale = 0.75, 1.5 | 229 self.sprite.rescale = 0.75, 1.5 |
230 self._sprite.fade(26, 96, lambda x: x) | 230 self.sprite.fade(26, 96, lambda x: x) |
231 self._sprite.scale_in(26, 0.00, 2.5, lambda x: x) | 231 self.sprite.scale_in(26, 0.00, 2.5, lambda x: x) |
232 | 232 |
233 elif time == 32: | 233 elif time == 32: |
234 self.state.x = float(self._game.width) / 2. #TODO | 234 self.state.x = float(self._game.width) / 2. #TODO |
235 self.state.y = float(self._game.width) #TODO | 235 self.state.y = float(self._game.width) #TODO |
236 self.direction = None | 236 self.direction = None |
237 | 237 |
238 self._sprite = Sprite() | 238 self.sprite = Sprite() |
239 self._anmrunner = ANMRunner(self.anm_wrapper, 0, self._sprite) | 239 self.anmrunner = ANMRunner(self.anm_wrapper, 0, self.sprite) |
240 self._sprite.alpha = 128 | 240 self.sprite.alpha = 128 |
241 self._sprite.rescale = 0.0, 2.5 | 241 self.sprite.rescale = 0.0, 2.5 |
242 self._sprite.fade(30, 255, lambda x: x) | 242 self.sprite.fade(30, 255, lambda x: x) |
243 self._sprite.blendfunc = 1 | 243 self.sprite.blendfunc = 1 |
244 self._sprite.scale_in(30, 1., 1., lambda x: x) | 244 self.sprite.scale_in(30, 1., 1., lambda x: x) |
245 self._anmrunner.run_frame() | 245 self.anmrunner.run_frame() |
246 | 246 |
247 elif time == 61: # respawned | 247 elif time == 61: # respawned |
248 self.state.touchable = True | 248 self.state.touchable = True |
249 self.state.invulnerable_time = 240 | 249 self.state.invulnerable_time = 240 |
250 self._sprite.blendfunc = 0 | 250 self.sprite.blendfunc = 0 |
251 self._sprite._changed = True | 251 self.sprite.changed = True |
252 | 252 |
253 if time > 30: | 253 if time > 30: |
254 for bullet in self._game.bullets: | 254 for bullet in self._game.bullets: |
255 bullet.cancel() | 255 bullet.cancel() |
256 for laser in self._game.lasers: | 256 for laser in self._game.lasers: |
257 laser.cancel() | 257 laser.cancel() |
258 | 258 |
259 if time > 90: # start the bullet hell again | 259 if time > 90: # start the bullet hell again |
260 self.death_time = 0 | 260 self.death_time = 0 |
261 | 261 |
262 self._anmrunner.run_frame() | 262 self.anmrunner.run_frame() |
263 | 263 |