From a4aa20e306e7d6c76516c827137beed6121d6d55 Mon Sep 17 00:00:00 2001 From: Nick Dyer Date: Fri, 4 Jun 2021 23:26:56 -0400 Subject: [PATCH] added scrolling to the InfoText class --- pocket_friends/game_files/game.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pocket_friends/game_files/game.py b/pocket_friends/game_files/game.py index 602b104..4668ece 100644 --- a/pocket_friends/game_files/game.py +++ b/pocket_friends/game_files/game.py @@ -200,6 +200,21 @@ class InfoText: text = self.font.render(self.text[i + self.offset], False, (64, 64, 64)) surface.blit(text, (3, 22 + (i * 7))) + def scroll_down(self): + """ + Scrolls the text on the screen down. + """ + # Ensures that the offset cannot be too big as to try to render non-existent lines. + if len(self.text) - (self.offset + 1) >= self.max_lines: + self.offset += 1 + + def scroll_up(self): + """ + Scrolls the text on the screen up. + """ + if self.offset > 0: # Ensures a non-zero offset is not possible. + self.offset -= 1 + # Makes Pygame draw on the display of the RPi. os.environ["SDL_FBDEV"] = "/dev/fb1"