comparison pytouhou/game/player.pyx @ 447:78e1c3864e73

Make pytouhou.game.game an extension type.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 17 Aug 2013 06:29:53 +0200
parents b0abb05811f7
children 4ccc47828002
comparison
equal deleted inserted replaced
446:3a33ed7f3b85 447:78e1c3864e73
53 return PlayerState(self.character, self.score, 53 return PlayerState(self.character, self.score,
54 self.power, self.lives, self.bombs) 54 self.power, self.lives, self.bombs)
55 55
56 56
57 cdef class Player(Element): 57 cdef class Player(Element):
58 def __init__(self, PlayerState state, game, anm): 58 def __init__(self, PlayerState state, Game game, anm):
59 Element.__init__(self) 59 Element.__init__(self)
60 60
61 self._game = game 61 self._game = game
62 self.anm = anm 62 self.anm = anm
63 63
115 if self.state.power < shot_power: 115 if self.state.power < shot_power:
116 power = power if power < shot_power else shot_power 116 power = power if power < shot_power else shot_power
117 117
118 bullets = self._game.players_bullets 118 bullets = self._game.players_bullets
119 lasers = self._game.players_lasers 119 lasers = self._game.players_lasers
120 nb_bullets_max = <long>self._game.nb_bullets_max 120 nb_bullets_max = self._game.nb_bullets_max
121 121
122 if self.fire_time % 5 == 0: 122 if self.fire_time % 5 == 0:
123 self.play_sound('plst00') 123 self.play_sound('plst00')
124 124
125 for shot in sht.shots[power]: 125 for shot in sht.shots[power]:
229 if self.fire_time > 0: 229 if self.fire_time > 0:
230 self.fire() 230 self.fire()
231 self.fire_time -= 1 231 self.fire_time -= 1
232 232
233 if self.death_time: 233 if self.death_time:
234 time = <long>self._game.frame - self.death_time 234 time = self._game.frame - self.death_time
235 if time == 6: # too late, you are dead :( 235 if time == 6: # too late, you are dead :(
236 self.state.touchable = False 236 self.state.touchable = False
237 if self.state.power > 16: 237 if self.state.power > 16:
238 self.state.power -= 16 238 self.state.power -= 16
239 else: 239 else:
275 self.sprite.blendfunc = 0 275 self.sprite.blendfunc = 0
276 self.sprite.rescale = 0.75, 1.5 276 self.sprite.rescale = 0.75, 1.5
277 self.sprite.fade(26, 96) 277 self.sprite.fade(26, 96)
278 self.sprite.scale_in(26, 0., 2.5) 278 self.sprite.scale_in(26, 0., 2.5)
279 279
280 #TODO: the next two branches could be happening at the same frame.
281 elif time == 31:
282 self._game.cancel_bullets()
283
280 elif time == 32: 284 elif time == 32:
281 self.state.x = float(self._game.width) / 2. #TODO 285 self.state.x = float(self._game.width) / 2. #TODO
282 self.state.y = float(self._game.width) #TODO 286 self.state.y = float(self._game.width) #TODO
283 self.direction = 0 287 self.direction = 0
284 288
294 self.state.touchable = True 298 self.state.touchable = True
295 self.state.invulnerable_time = 240 299 self.state.invulnerable_time = 240
296 self.sprite.blendfunc = 0 300 self.sprite.blendfunc = 0
297 self.sprite.changed = True 301 self.sprite.changed = True
298 302
299 if time > 30: 303 elif time == 91: # start the bullet hell again
300 self._game.cancel_bullets()
301
302 if time > 90: # start the bullet hell again
303 self.death_time = 0 304 self.death_time = 0
304 305
305 self.anmrunner.run_frame() 306 self.anmrunner.run_frame()
306 307