projects
/
base2-runner.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
77e6bdc
)
Streamline the styled text printing code
author
TJ
<git@iam.tj>
Thu, 14 Nov 2013 23:15:46 +0000
(23:15 +0000)
committer
TJ
<git@iam.tj>
Thu, 14 Nov 2013 23:15:46 +0000
(23:15 +0000)
engine/Game.py
patch
|
blob
|
history
diff --git
a/engine/Game.py
b/engine/Game.py
index
d20ab21
..
82fd241
100755
(executable)
--- a/
engine/Game.py
+++ b/
engine/Game.py
@@
-11,13
+11,14
@@
class Style:
font = None
colour = None
height = 0
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
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 """
class Game:
""" Container for all game state and configuration items """
@@
-77,7
+78,7
@@
class Game:
# splash screen
self.splash()
# 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'
""" 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')
# 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
# print the Soundtrack copyright information
- self.print('Soundtrack:',
'body'
)
+ self.print('Soundtrack:',)
self.print_x += 20 # indent
for key in ('copyright', 'license', 'url'):
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 = "%
12
s: %s" % (key, self.resources["soundtrack.%s" % key])
+ self.print(text)
pygame.display.update()
pygame.display.update()