# HG changeset patch # User Thibaut Girka # Date 1315175371 -7200 # Node ID 5c40cc1b8019d558b656a87a4fc9fc5cad513876 # Parent 68aa8bf00c88020556d8a230bb536efa5b5fdf6f Use game's frame for interpolation. No more time manipulation interfering with interpolators! diff --git a/eclviewer.py b/eclviewer.py --- a/eclviewer.py +++ b/eclviewer.py @@ -35,6 +35,8 @@ from OpenGL.GLU import * def main(path, stage_num): + import logging + logging.basicConfig(level=logging.DEBUG) # Initialize pygame pygame.init() window = pygame.display.set_mode((384, 448), pygame.OPENGL | pygame.DOUBLEBUF) diff --git a/pytouhou/game/enemy.py b/pytouhou/game/enemy.py --- a/pytouhou/game/enemy.py +++ b/pytouhou/game/enemy.py @@ -130,14 +130,15 @@ class Enemy(object): def set_pos(self, x, y, z): self.x, self.y = x, y self.interpolator = Interpolator((x, y)) - self.interpolator.set_interpolation_start(self.frame, (x, y)) + self.interpolator.set_interpolation_start(self._game_state.frame, (x, y)) def move_to(self, duration, x, y, z, formula): if not self.interpolator: + frame = self._game_state.frame self.interpolator = Interpolator((self.x, self.y), formula) - self.interpolator.set_interpolation_start(self.frame, (self.x, self.y)) - self.interpolator.set_interpolation_end(self.frame + duration - 1, (x, y)) + self.interpolator.set_interpolation_start(frame, (self.x, self.y)) + self.interpolator.set_interpolation_end(frame + duration - 1, (x, y)) self.speed = 0. self.angle = atan2(y - self.y, x - self.x) @@ -145,9 +146,10 @@ class Enemy(object): def stop_in(self, duration, formula): if not self.speed_interpolator: + frame = self._game_state.frame self.speed_interpolator = Interpolator((self.speed,), formula) - self.speed_interpolator.set_interpolation_start(self.frame, (self.speed,)) - self.speed_interpolator.set_interpolation_end(self.frame + duration - 1, (0.,)) + self.speed_interpolator.set_interpolation_start(frame, (self.speed,)) + self.speed_interpolator.set_interpolation_end(frame + duration - 1, (0.,)) self.speed = 0. @@ -195,7 +197,7 @@ class Enemy(object): def update(self): x, y = self.x, self.y if self.interpolator: - self.interpolator.update(self.frame) + self.interpolator.update(self._game_state.frame) x, y = self.interpolator.values self.speed += self.acceleration #TODO: units? Execution order? @@ -203,7 +205,7 @@ class Enemy(object): if self.speed_interpolator: - self.speed_interpolator.update(self.frame) + self.speed_interpolator.update(self._game_state.frame) self.speed, = self.speed_interpolator.values diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -152,6 +152,7 @@ class ECLRunner(object): logger.warn('unhandled opcode %d (args: %r)', instr_type, args) else: callback(self, *args) + logger.debug('executed opcode %d (args: %r)', instr_type, args) self.frame += 1 return True