Mercurial > touhou
comparison pytouhou/game/enemy.py @ 437:d778db08190f
Make Interpolator an extension type.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 07 Aug 2013 11:34:44 +0200 |
parents | 1222341ea22c |
children | b9d2db93972f |
comparison
equal
deleted
inserted
replaced
436:cb5c68598ab0 | 437:d778db08190f |
---|---|
247 | 247 |
248 | 248 |
249 def set_pos(self, x, y, z): | 249 def set_pos(self, x, y, z): |
250 self.x, self.y = x, y | 250 self.x, self.y = x, y |
251 self.update_mode = 1 | 251 self.update_mode = 1 |
252 self.interpolator = Interpolator((x, y)) | 252 self.interpolator = Interpolator((x, y), self._game.frame) |
253 self.interpolator.set_interpolation_start(self._game.frame, (x, y)) | |
254 | 253 |
255 | 254 |
256 def move_to(self, duration, x, y, z, formula): | 255 def move_to(self, duration, x, y, z, formula): |
257 frame = self._game.frame | 256 frame = self._game.frame |
258 self.speed_interpolator = None | 257 self.speed_interpolator = None |
259 self.update_mode = 1 | 258 self.update_mode = 1 |
260 self.interpolator = Interpolator((self.x, self.y), formula) | 259 self.interpolator = Interpolator((self.x, self.y), frame, |
261 self.interpolator.set_interpolation_start(frame, (self.x, self.y)) | 260 (x, y), frame + duration - 1, |
262 self.interpolator.set_interpolation_end(frame + duration - 1, (x, y)) | 261 formula) |
263 | 262 |
264 self.angle = atan2(y - self.y, x - self.x) | 263 self.angle = atan2(y - self.y, x - self.x) |
265 | 264 |
266 | 265 |
267 def stop_in(self, duration, formula): | 266 def stop_in(self, duration, formula): |
268 frame = self._game.frame | 267 frame = self._game.frame |
269 self.interpolator = None | 268 self.interpolator = None |
270 self.update_mode = 1 | 269 self.update_mode = 1 |
271 self.speed_interpolator = Interpolator((self.speed,), formula) | 270 self.speed_interpolator = Interpolator((self.speed,), frame, |
272 self.speed_interpolator.set_interpolation_start(frame, (self.speed,)) | 271 (0.,), frame + duration - 1, |
273 self.speed_interpolator.set_interpolation_end(frame + duration - 1, (0.,)) | 272 formula) |
274 | 273 |
275 | 274 |
276 def is_visible(self, screen_width, screen_height): | 275 def is_visible(self, screen_width, screen_height): |
277 if self.sprite: | 276 if self.sprite: |
278 tx, ty, tw, th = self.sprite.texcoords | 277 tx, ty, tw, th = self.sprite.texcoords |