comparison pytouhou/game/player.py @ 339:7a05edbab88a

Implement continues when the lives fall bellow 0.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 04 Jul 2012 21:38:00 +0200
parents 2350147cf043
children 94fdb6c782c1
comparison
equal deleted inserted replaced
338:65453340ae95 339:7a05edbab88a
17 from pytouhou.vm.anmrunner import ANMRunner 17 from pytouhou.vm.anmrunner import ANMRunner
18 from pytouhou.game.bullettype import BulletType 18 from pytouhou.game.bullettype import BulletType
19 from pytouhou.game.bullet import Bullet 19 from pytouhou.game.bullet import Bullet
20 from pytouhou.game.lasertype import LaserType 20 from pytouhou.game.lasertype import LaserType
21 from pytouhou.game.laser import PlayerLaser 21 from pytouhou.game.laser import PlayerLaser
22 from pytouhou.game.game import GameOver
22 23
23 from math import pi 24 from math import pi
24 25
25 26
26 class PlayerState(object): 27 class PlayerState(object):
212 213
213 if self.death_time: 214 if self.death_time:
214 time = self._game.frame - self.death_time 215 time = self._game.frame - self.death_time
215 if time == 6: # too late, you are dead :( 216 if time == 6: # too late, you are dead :(
216 self.state.touchable = False 217 self.state.touchable = False
217 self.state.lives -= 1
218 if self.state.power > 16: 218 if self.state.power > 16:
219 self.state.power -= 16 219 self.state.power -= 16
220 else: 220 else:
221 self.state.power = 0 221 self.state.power = 0
222 222
223 self._game.drop_bonus(self.state.x, self.state.y, 2, 223 self.state.lives -= 1
224 end_pos=(self._game.prng.rand_double() * 288 + 48, # 102h.exe@0x41f3dc 224 if self.state.lives < 0:
225 self._game.prng.rand_double() * 192 - 64)) # @0x41f3 225 #TODO: display a menu to ask the players if they want to continue.
226 for i in range(5): 226 self._game.continues -= 1
227 self._game.drop_bonus(self.state.x, self.state.y, 0, 227 if self._game.continues < 0:
228 end_pos=(self._game.prng.rand_double() * 288 + 48, 228 raise GameOver
229 self._game.prng.rand_double() * 192 - 64)) 229
230 for i in range(5):
231 self._game.drop_bonus(self.state.x, self.state.y, 4,
232 end_pos=(self._game.prng.rand_double() * 288 + 48,
233 self._game.prng.rand_double() * 192 - 64))
234 self.state.score = 0
235 self.state.effective_score = 0
236 self.state.lives = 2 #TODO: use the right default.
237 self.state.bombs = 3 #TODO: use the right default.
238 self.state.power = 0
239
240 self.state.graze = 0
241 self.state.points = 0
242 else:
243 self._game.drop_bonus(self.state.x, self.state.y, 2,
244 end_pos=(self._game.prng.rand_double() * 288 + 48, # 102h.exe@0x41f3dc
245 self._game.prng.rand_double() * 192 - 64)) # @0x41f3
246 for i in range(5):
247 self._game.drop_bonus(self.state.x, self.state.y, 0,
248 end_pos=(self._game.prng.rand_double() * 288 + 48,
249 self._game.prng.rand_double() * 192 - 64))
230 250
231 elif time == 7: 251 elif time == 7:
232 self.sprite.mirrored = False 252 self.sprite.mirrored = False
233 self.sprite.blendfunc = 0 253 self.sprite.blendfunc = 0
234 self.sprite.rescale = 0.75, 1.5 254 self.sprite.rescale = 0.75, 1.5