Mercurial > touhou
comparison pytouhou/game/bullet.py @ 161:7e7368356445
Add bullet cancel anim support
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 11 Oct 2011 11:29:33 +0200 |
parents | 7769ce7be03c |
children | ee0bbde02c48 |
comparison
equal
deleted
inserted
replaced
160:606468ab4f7b | 161:7e7368356445 |
---|---|
106 self.speed_interpolator = Interpolator((self.speed + 5.,), 0, | 106 self.speed_interpolator = Interpolator((self.speed + 5.,), 0, |
107 (self.speed,), 16) | 107 (self.speed,), 16) |
108 | 108 |
109 | 109 |
110 def collide(self): | 110 def collide(self): |
111 #TODO: animation | 111 self.cancel() |
112 self._removed = True | 112 |
113 | |
114 def cancel(self): | |
115 # Cancel animation | |
116 bt = self._bullet_type | |
117 self._sprite = Sprite() | |
118 self._sprite.angle = self.angle | |
119 self._anmrunner = ANMRunner(bt.anm_wrapper, bt.cancel_anim_index, | |
120 self._sprite, bt.launch_anim_offsets[self.sprite_idx_offset]) | |
121 self._anmrunner.run_frame() | |
122 | |
123 # Change update method | |
124 self.update = self.update_cancel | |
125 | |
126 # Do not use this one for collisions anymore | |
127 self._game.bullets.remove(self) | |
128 self._game.cancelled_bullets.append(self) | |
113 | 129 |
114 | 130 |
115 def update(self): | 131 def update(self): |
116 dx, dy = self.launch_delta | 132 dx, dy = self.launch_delta |
117 self.x += dx | 133 self.x += dx |
118 self.y += dy | 134 self.y += dy |
119 | 135 |
120 if not self._anmrunner.run_frame(): | 136 if not self._anmrunner.run_frame(): |
121 self.launch() | 137 self.launch() |
138 | |
139 | |
140 def update_cancel(self): | |
141 dx, dy = self.delta | |
142 self.x += dx | |
143 self.y += dy | |
144 | |
145 if not self._anmrunner.run_frame(): | |
146 self._removed = True | |
122 | 147 |
123 | 148 |
124 def update_simple(self): | 149 def update_simple(self): |
125 dx, dy = self.delta | 150 dx, dy = self.delta |
126 self.x += dx | 151 self.x += dx |