From: TJ Date: Thu, 14 Nov 2013 23:15:46 +0000 (+0000) Subject: Streamline the styled text printing code X-Git-Url: https://iam.tj/gitweb/gitweb.cgi?p=base2-runner.git;a=commitdiff_plain;h=7757ce23e102e29a51385c25f3c42976c5e3f017 Streamline the styled text printing code --- diff --git a/engine/Game.py b/engine/Game.py index d20ab21..82fd241 100755 --- a/engine/Game.py +++ b/engine/Game.py @@ -11,13 +11,14 @@ class Style: font = None colour = None height = 0 + debug = False def __init__(self, font, height, colour, debug=False): self.font = pygame.font.Font(font, height) self.height = height self.colour = colour - self.debug = debug - if self.debug: engine.debug_pr("Style %s, height: %d, colour:" % (font, height), self.colour) + Style.debug = debug + if Style.debug: engine.debug_pr("Style %s, height: %d, colour:" % (font, height), self.colour) class Game: """ Container for all game state and configuration items """ @@ -77,7 +78,7 @@ class Game: # splash screen self.splash() - def print(self, text, style): + def print(self, text, style='body'): """ print a line of text and move the text origin to the next line """ if not style in self.styles: style = 'body' @@ -102,13 +103,13 @@ class Game: # print the Game title and copyright self.print_x, self.print_y = 40, 40 # indent self.print(self.resources['title'], 'h1') - self.print(self.resources['copyright'], 'body') + self.print(self.resources['copyright']) # print the Soundtrack copyright information - self.print('Soundtrack:', 'body') + self.print('Soundtrack:',) self.print_x += 20 # indent for key in ('copyright', 'license', 'url'): - text = "%s: %s" % (key, self.resources["soundtrack.%s" % key]) - self.print(text, 'body') + text = "%12s: %s" % (key, self.resources["soundtrack.%s" % key]) + self.print(text) pygame.display.update()