Mercurial > touhou
comparison pytouhou/game/orb.py @ 471:06f0eeb519bb
Make Laser and Orb extension types, and use that where possible.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 16 Sep 2013 18:42:04 +0200 |
parents | b9d2db93972f |
children | 6be9c99a3a24 |
comparison
equal
deleted
inserted
replaced
470:98995d8ac744 | 471:06f0eeb519bb |
---|---|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 ## GNU General Public License for more details. | 12 ## GNU General Public License for more details. |
13 ## | 13 ## |
14 | 14 |
15 | |
16 from pytouhou.game.element import Element | |
17 from pytouhou.game.sprite import Sprite | |
18 from pytouhou.vm.anmrunner import ANMRunner | 15 from pytouhou.vm.anmrunner import ANMRunner |
19 | 16 |
20 | 17 |
21 class Orb(Element): | 18 class Orb(Element): |
22 __slots__ = ('offset_x', 'offset_y', 'player_state', 'fire') | 19 def __init__(self, anm, index, player_state): |
23 | |
24 def __init__(self, anm, index, player_state, fire_func): | |
25 Element.__init__(self) | 20 Element.__init__(self) |
26 | 21 |
27 self.sprite = Sprite() | 22 self.sprite = Sprite() |
28 self.anmrunner = ANMRunner(anm, index, self.sprite) | 23 self.anmrunner = ANMRunner(anm, index, self.sprite) |
29 | 24 |
30 self.offset_x = 0 | 25 self.offset_x = 0 |
31 self.offset_y = 0 | 26 self.offset_y = 0 |
32 | 27 |
33 self.player_state = player_state | 28 self.player_state = player_state |
34 self.fire = fire_func | |
35 | |
36 | |
37 @property | |
38 def x(self): | |
39 return self.player_state.x + self.offset_x | |
40 | |
41 | |
42 @property | |
43 def y(self): | |
44 return self.player_state.y + self.offset_y | |
45 | 29 |
46 | 30 |
47 def update(self): | 31 def update(self): |
48 self.anmrunner.run_frame() | 32 self.anmrunner.run_frame() |
49 | 33 self.x = self.player_state.x + self.offset_x |
34 self.y = self.player_state.y + self.offset_y |