Mercurial > touhou
diff pytouhou/utils/interpolator.py @ 50:811cefefb5c8
Fix a few bugs and add support for a few instructions
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 22 Aug 2011 21:16:47 +0200 |
parents | 6ebf9539c077 |
children | ab826bc29aa2 |
line wrap: on
line diff
--- a/pytouhou/utils/interpolator.py +++ b/pytouhou/utils/interpolator.py @@ -5,6 +5,7 @@ class Interpolator(object): self.end_values = tuple(values) self.start_frame = 0 self.end_frame = 0 + self._frame = 0 def set_interpolation_start(self, frame, values): @@ -26,12 +27,15 @@ class Interpolator(object): def update(self, frame): + self._frame = frame if frame >= self.end_frame: self.values = tuple(self.end_values) self.start_values = tuple(self.end_values) self.start_frame = frame + return frame == self.end_frame else: truc = float(frame - self.start_frame) / float(self.end_frame - self.start_frame) self.values = tuple(start_value + truc * (end_value - start_value) for (start_value, end_value) in zip(self.start_values, self.end_values)) + return True