Streamline the styled text printing code
authorTJ <git@iam.tj>
Thu, 14 Nov 2013 23:15:46 +0000 (23:15 +0000)
committerTJ <git@iam.tj>
Thu, 14 Nov 2013 23:15:46 +0000 (23:15 +0000)
engine/Game.py

index d20ab21..82fd241 100755 (executable)
@@ -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()