From e1e3f35be02cc96c8dea6d9eaf6dbb444c9d98ac Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 19 Mar 2013 11:30:59 +0100 Subject: [PATCH] Calculate lastframe_limit only one time, as it does not change --- pygame-vertical-scrolling-map.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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)) -- 2.1.4