Mercurial > fife-parpg
comparison demos/shooter/scripts/ships/player.py @ 459:302a69c5141d
Player death is now handled a bit nicer.
Added invulnerability.
Added 3 more enemy types.
Fixed a bug in the collision detection routine that caused some objects not to be updated when a collision is detected.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 09 Apr 2010 17:35:52 +0000 |
parents | 597b066d5ccb |
children | 5e1d6e40d19d |
comparison
equal
deleted
inserted
replaced
458:e77ebf128a74 | 459:302a69c5141d |
---|---|
36 | 36 |
37 #give player the default weapon (the cannon) | 37 #give player the default weapon (the cannon) |
38 self.weapon = Cannon(self._scene, self, 200) | 38 self.weapon = Cannon(self._scene, self, 200) |
39 | 39 |
40 self._lives = 3 | 40 self._lives = 3 |
41 self._invulnerable = False | |
41 | 42 |
42 def init(self): | 43 def init(self): |
43 self._lives = 3 | 44 self._lives = 3 |
44 | 45 |
45 def _getScore(self): | 46 def _getScore(self): |
47 | 48 |
48 def applyScore(self, sc): | 49 def applyScore(self, sc): |
49 self._score += sc | 50 self._score += sc |
50 | 51 |
51 def destroy(self): | 52 def destroy(self): |
52 self._lives -= 1 | 53 if not self._flashing: |
54 self._lives -= 1 | |
53 | 55 |
54 if self._lives < 0: | 56 if self._lives < 0: |
55 self._lives = -1 | 57 self._lives = -1 |
56 | 58 |
57 | 59 def setInvulnerable(self, seconds): |
60 self.flash(20, 20*seconds) | |
61 self._invulnerable = True | |
62 | |
58 def update(self): | 63 def update(self): |
59 | 64 |
60 key = False | 65 key = False |
66 | |
67 #player is no longer invulnerable | |
68 if not self._flashing and self._invulnerable: | |
69 self._invulnerable = False | |
61 | 70 |
62 oldpos = self.location | 71 oldpos = self.location |
63 | 72 |
64 if self._scene.keystate['UP']: | 73 if self._scene.keystate['UP']: |
65 self.applyThrust(fife.DoublePoint(0,-1.5)) | 74 self.applyThrust(fife.DoublePoint(0,-1.5)) |
114 | 123 |
115 self.location = oldpos | 124 self.location = oldpos |
116 | 125 |
117 def _getLives(self): | 126 def _getLives(self): |
118 return self._lives | 127 return self._lives |
128 | |
129 def _getInvulnerable(self): | |
130 return self._invulnerable | |
119 | 131 |
120 score = property(_getScore) | 132 score = property(_getScore) |
121 lives = property(_getLives) | 133 lives = property(_getLives) |
134 invulnerable = property(_getInvulnerable) |