caption
This commit is contained in:
parent
a6efd6580d
commit
184a1f2c2f
4
config
4
config
|
@ -1,6 +1,8 @@
|
||||||
[display]
|
[display]
|
||||||
|
caption = Electric Sieve
|
||||||
dimensions = 420, 700
|
dimensions = 420, 700
|
||||||
font-path = Titan-One.ttf
|
score-font-path = Titan-One.ttf
|
||||||
|
title-font-path = Oxygen.ttf
|
||||||
|
|
||||||
[mouse]
|
[mouse]
|
||||||
visible = no
|
visible = no
|
||||||
|
|
|
@ -42,8 +42,37 @@ class Title(GameChild):
|
||||||
GameChild.__init__(self, parent)
|
GameChild.__init__(self, parent)
|
||||||
self.display_surface = self.get_display_surface()
|
self.display_surface = self.get_display_surface()
|
||||||
self.delegate = self.parent.delegate
|
self.delegate = self.parent.delegate
|
||||||
|
bg_color = (255, 222, 173)
|
||||||
self.background = surface = Surface(self.display_surface.get_size())
|
self.background = surface = Surface(self.display_surface.get_size())
|
||||||
surface.fill((0, 255, 255))
|
tile = Surface((2, 2))
|
||||||
|
tile.fill(bg_color)
|
||||||
|
tile.set_at((0, 1), (220, 119, 41))
|
||||||
|
tile.set_at((1, 0), (220, 119, 41))
|
||||||
|
for y in xrange(0, surface.get_height(), 2):
|
||||||
|
for x in xrange(0, surface.get_width(), 2):
|
||||||
|
surface.blit(tile, (x, y))
|
||||||
|
font = Font(self.get_resource("display", "title-font-path"), 20)
|
||||||
|
font.set_italic(True)
|
||||||
|
font.set_bold(True)
|
||||||
|
self.captions = captions = Sprite(self), Sprite(self)
|
||||||
|
colors = (255, 204, 0), (0, 68, 170), (255, 255, 255), (128, 128, 128), \
|
||||||
|
(220, 119, 41)
|
||||||
|
texts = ["", ""]
|
||||||
|
for ii, text in \
|
||||||
|
enumerate(self.get_configuration("display",
|
||||||
|
"caption").upper().split()):
|
||||||
|
texts[ii] += "•" * (5 if ii else 3)
|
||||||
|
for ch in text:
|
||||||
|
texts[ii] += ch + " "
|
||||||
|
texts[ii] = texts[ii].strip() + "•" * (5 if ii else 3)
|
||||||
|
for _ in xrange(25):
|
||||||
|
color = choice(colors)
|
||||||
|
captions[0].add_frame(font.render(texts[0], True, color, (220, 208, 255)))
|
||||||
|
captions[1].add_frame(font.render(texts[1], True, color, (220, 208, 255)))
|
||||||
|
cx = self.display_surface.get_rect().centerx
|
||||||
|
captions[0].location.center = cx, 301
|
||||||
|
captions[1].location.center = cx, 398
|
||||||
|
self.scoreboard = Scoreboard(self)
|
||||||
self.subscribe(self.respond)
|
self.subscribe(self.respond)
|
||||||
|
|
||||||
def respond(self, event):
|
def respond(self, event):
|
||||||
|
@ -56,6 +85,7 @@ class Title(GameChild):
|
||||||
|
|
||||||
def activate(self):
|
def activate(self):
|
||||||
self.active = True
|
self.active = True
|
||||||
|
self.scoreboard.activate()
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
self.active = False
|
self.active = False
|
||||||
|
@ -63,6 +93,9 @@ class Title(GameChild):
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.active:
|
if self.active:
|
||||||
self.display_surface.blit(self.background, (0, 0))
|
self.display_surface.blit(self.background, (0, 0))
|
||||||
|
for caption in self.captions:
|
||||||
|
caption.update()
|
||||||
|
self.scoreboard.update()
|
||||||
|
|
||||||
|
|
||||||
class Strip(Sprite):
|
class Strip(Sprite):
|
||||||
|
@ -134,6 +167,16 @@ class Shift(GameChild):
|
||||||
return self.nodeset.get_y(self.time) * self.direction
|
return self.nodeset.get_y(self.time) * self.direction
|
||||||
|
|
||||||
|
|
||||||
|
class Scoreboard(Strip):
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
Strip.__init__(self, parent)
|
||||||
|
surface = Surface((380, 80))
|
||||||
|
surface.fill((255, 255, 255))
|
||||||
|
self.add_frame(surface)
|
||||||
|
self.location.center = self.display_surface.get_rect().centerx, 350
|
||||||
|
|
||||||
|
|
||||||
class Sieve(Strip):
|
class Sieve(Strip):
|
||||||
|
|
||||||
UP, DOWN = range(2)
|
UP, DOWN = range(2)
|
||||||
|
@ -438,7 +481,7 @@ class Total(Sprite):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
Sprite.__init__(self, parent, 68)
|
Sprite.__init__(self, parent, 68)
|
||||||
self.deactivate()
|
self.deactivate()
|
||||||
self.font = Font(self.get_resource("display", "font-path"), 48)
|
self.font = Font(self.get_resource("display", "score-font-path"), 48)
|
||||||
self.font.set_italic(True)
|
self.font.set_italic(True)
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
|
|
Loading…
Reference in New Issue