From: Antonio Ospite Date: Tue, 19 Mar 2013 10:30:59 +0000 (+0100) Subject: Calculate lastframe_limit only one time, as it does not change X-Git-Url: https://git.ao2.it/experiments/pygame.git/commitdiff_plain/e1e3f35be02cc96c8dea6d9eaf6dbb444c9d98ac?ds=sidebyside Calculate lastframe_limit only one time, as it does not change --- diff --git a/pygame-vertical-scrolling-map.py b/pygame-vertical-scrolling-map.py index 132b44a..75227e1 100755 --- a/pygame-vertical-scrolling-map.py +++ b/pygame-vertical-scrolling-map.py @@ -50,15 +50,15 @@ class VerticalScrollingMap(pygame.Surface): # Center along X self.x = (self.viewport_width - self.texture_widht) / 2.0 - def draw(self, screen): - self.y += self.offset - # NOTE, we assume that the texture has at least twice the height of the # viewport - lastframe_limit = -(self.texture_height - self.viewport_height) + self.lastframe_limit = -(self.texture_height - self.viewport_height) + + def draw(self, screen): + self.y += self.offset # Wrap around to cycle seamlessly - self.y %= lastframe_limit + self.y %= self.lastframe_limit screen.blit(self.texture, (self.x, self.y))