Mercurial > touhou
comparison pytouhou/games/eosd.py @ 206:eca53abdfeab
Fix ReimuA, and refactor Player a bit.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 05 Nov 2011 19:43:11 +0100 |
parents | 300661f2ae8a |
children | a842ddd471fd |
comparison
equal
deleted
inserted
replaced
205:ee6dfd14a785 | 206:eca53abdfeab |
---|---|
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 from pytouhou.utils.interpolator import Interpolator | |
15 | 16 |
16 from pytouhou.game.game import Game | 17 from pytouhou.game.game import Game |
17 from pytouhou.game.bullettype import BulletType | 18 from pytouhou.game.bullettype import BulletType |
18 from pytouhou.game.itemtype import ItemType | 19 from pytouhou.game.itemtype import ItemType |
19 from pytouhou.game.player import Player | 20 from pytouhou.game.player import Player |
53 | 54 |
54 Game.__init__(self, resource_loader, players, stage, rank, difficulty, | 55 Game.__init__(self, resource_loader, players, stage, rank, difficulty, |
55 bullet_types, item_types, nb_bullets_max=640, **kwargs) | 56 bullet_types, item_types, nb_bullets_max=640, **kwargs) |
56 | 57 |
57 | 58 |
58 class Reimu(Player): | 59 |
60 class EoSDPlayer(Player): | |
61 def __init__(self, state, game, anm_wrapper, speed=4., hitbox_size=2.5, graze_hitbox_size=42.): | |
62 Player.__init__(self, state, game, anm_wrapper, speed=4.) | |
63 | |
64 self.orbs = [Orb(self.anm_wrapper, 128, self.state, self.orb_fire), | |
65 Orb(self.anm_wrapper, 129, self.state, self.orb_fire)] | |
66 | |
67 self.orbs[0].offset_x = -24 | |
68 self.orbs[1].offset_x = 24 | |
69 | |
70 self.orb_dx_interpolator = None | |
71 self.orb_dy_interpolator = None | |
72 | |
73 | |
74 def start_focusing(self): | |
75 self.orb_dx_interpolator = Interpolator((24,), self._game.frame, | |
76 (8,), self._game.frame + 8, | |
77 lambda x: x ** 2) | |
78 self.orb_dy_interpolator = Interpolator((0,), self._game.frame, | |
79 (-32,), self._game.frame + 8) | |
80 self.state.focused = True | |
81 | |
82 | |
83 def stop_focusing(self): | |
84 self.orb_dx_interpolator = Interpolator((8,), self._game.frame, | |
85 (24,), self._game.frame + 8, | |
86 lambda x: x ** 2) | |
87 self.orb_dy_interpolator = Interpolator((-32,), self._game.frame, | |
88 (0,), self._game.frame + 8) | |
89 self.state.focused = False | |
90 | |
91 | |
92 def objects(self): | |
93 return self.orbs if self.state.power >= 8 else [] | |
94 | |
95 | |
96 def update(self, keystate): | |
97 Player.update(self, keystate) | |
98 | |
99 if self.death_time == 0 or self._game.frame - self.death_time > 60: | |
100 if self.orb_dx_interpolator: | |
101 self.orb_dx_interpolator.update(self._game.frame) | |
102 dx, = self.orb_dx_interpolator.values | |
103 self.orbs[0].offset_x = -dx | |
104 self.orbs[1].offset_x = dx | |
105 if self.orb_dy_interpolator: | |
106 self.orb_dy_interpolator.update(self._game.frame) | |
107 dy, = self.orb_dy_interpolator.values | |
108 self.orbs[0].offset_y = dy | |
109 self.orbs[1].offset_y = dy | |
110 | |
111 for orb in self.orbs: | |
112 orb.update() | |
113 | |
114 | |
115 def orb_fire(self, orb): | |
116 pass | |
117 | |
118 | |
119 | |
120 class Reimu(EoSDPlayer): | |
59 def __init__(self, state, game, resource_loader): | 121 def __init__(self, state, game, resource_loader): |
60 anm_wrapper = resource_loader.get_anm_wrapper(('player00.anm',)) | 122 anm_wrapper = resource_loader.get_anm_wrapper(('player00.anm',)) |
61 self.bullet_angle = pi/30 #TODO: check | 123 self.bullet_angle = pi/30 #TODO: check |
62 | 124 |
63 Player.__init__(self, state, game, anm_wrapper, speed=4.) | 125 EoSDPlayer.__init__(self, state, game, anm_wrapper, speed=4.) |
64 | 126 |
65 | 127 |
66 def fire(self): | 128 def fire(self): |
67 if self.fire_time % self.bullet_launch_interval == 0: | 129 if self.fire_time % self.bullet_launch_interval == 0: |
68 if self.state.power < 16: | 130 if self.state.power < 16: |
92 | 154 |
93 for orb in self.orbs: | 155 for orb in self.orbs: |
94 orb.fire(orb) | 156 orb.fire(orb) |
95 | 157 |
96 | 158 |
159 | |
97 class ReimuA(Reimu): | 160 class ReimuA(Reimu): |
98 def __init__(self, state, game, resource_loader): | 161 def __init__(self, state, game, resource_loader): |
99 Reimu.__init__(self, state, game, resource_loader) | 162 Reimu.__init__(self, state, game, resource_loader) |
100 | 163 |
101 self.bulletA_type = BulletType(self.anm_wrapper, 65, 97, 0, 0, 0, hitbox_size=4, damage=14) #TODO: verify the hitbox. | 164 self.bulletA_type = BulletType(self.anm_wrapper, 65, 97, 0, 0, 0, hitbox_size=4, damage=14) #TODO: verify the hitbox. |
110 | 173 |
111 else: | 174 else: |
112 pass #TODO | 175 pass #TODO |
113 | 176 |
114 | 177 |
178 | |
115 class ReimuB(Reimu): | 179 class ReimuB(Reimu): |
116 def __init__(self, state, game, resource_loader): | 180 def __init__(self, state, game, resource_loader): |
117 Reimu.__init__(self, state, game, resource_loader) | 181 Reimu.__init__(self, state, game, resource_loader) |
118 | 182 |
119 self.bulletB_type = BulletType(self.anm_wrapper, 66, 98, 0, 0, 0, hitbox_size=4, damage=12) #TODO: verify the hitbox. | 183 self.bulletB_type = BulletType(self.anm_wrapper, 66, 98, 0, 0, 0, hitbox_size=4, damage=12) #TODO: verify the hitbox. |
120 self.bulletB_speed = 22. | 184 self.bulletB_speed = 22. |
121 | |
122 self.orbs = [Orb(self.anm_wrapper, 128, self.state, self.orb_fire), | |
123 Orb(self.anm_wrapper, 129, self.state, self.orb_fire)] | |
124 self.orbs[0].offset_x = -24 | |
125 self.orbs[1].offset_x = 24 | |
126 | 185 |
127 | 186 |
128 def fire_spine(self, orb, offset_x): | 187 def fire_spine(self, orb, offset_x): |
129 bullets = self._game.players_bullets | 188 bullets = self._game.players_bullets |
130 nb_bullets_max = self._game.nb_bullets_max | 189 nb_bullets_max = self._game.nb_bullets_max |
174 if self.fire_time % 5 == 0: | 233 if self.fire_time % 5 == 0: |
175 self.fire_spine(orb, 0) | 234 self.fire_spine(orb, 0) |
176 | 235 |
177 | 236 |
178 | 237 |
179 class Marisa(Player): | 238 class Marisa(EoSDPlayer): |
180 def __init__(self, state, game, resource_loader): | 239 def __init__(self, state, game, resource_loader): |
181 anm_wrapper = resource_loader.get_anm_wrapper(('player01.anm',)) | 240 anm_wrapper = resource_loader.get_anm_wrapper(('player01.anm',)) |
182 self.bullet_angle = pi/40 #TODO: check | 241 self.bullet_angle = pi/40 #TODO: check |
183 | 242 |
184 Player.__init__(self, state, game, anm_wrapper, speed=5.) | 243 EoSDPlayer.__init__(self, state, game, anm_wrapper, speed=5.) |
185 | 244 |
186 | 245 |
187 def fire(self): | 246 def fire(self): |
188 if self.fire_time % self.bullet_launch_interval == 0: | 247 if self.fire_time % self.bullet_launch_interval == 0: |
189 if self.state.power < 32: | 248 if self.state.power < 32: |