# string = u"\u2250\u2254\u2258"
# font = Font(self.get_resource("display", "font"), 24)
# self.message = font.render(string, True, (0, 255, 0))
- self.backgrounds = [load(path) for path in \
+ self.backgrounds = [load(path).convert() for path in \
glob(self.get_resource("image", "background") + \
"*.png")]
self.used_backgrounds = []
def set_children(self):
Game.set_children(self)
self.title = Title(self)
+ self.floor = Floor(self)
def set_random_background(self):
index = choice(list(set(range(len(self.backgrounds))).\
def update(self):
self.get_screen().blit(self.background, (0, 0))
self.title.update()
+ self.floor.update()
# self.get_screen().fill((0, 0, 0))
# self.get_screen().blit(self.message, (100, 100))
self.deactivate()
def respond(self, event):
- if self.delegate.compare(event, "reset-game"):
+ if self.delegate.is_command(event) and \
+ self.delegate.compare(event, "reset-game"):
self.activate()
elif self.active:
if event.type == MOUSEBUTTONDOWN and event.button == 1:
self.text.update()
self.blit(self.mask, (0, 0), None, BLEND_RGBA_MIN)
self.ds.blit(self, (0, 0))
+
+
+class Floor(Sprite):
+
+ def __init__(self, parent):
+ Sprite.__init__(self, parent, 340)
+ base = load(self.get_resource("image", "brick")).convert()
+ ds = self.ds = self.get_display_surface()
+ surface = Surface((ds.get_width(), 17))
+ for swap in False, True:
+ frame = surface.copy()
+ tile = base.copy()
+ if swap:
+ pixels = PixelArray(tile)
+ foreground, background = pixels[1][1], pixels[0][0]
+ for x in xrange(len(pixels)):
+ for y in xrange(len(pixels[0])):
+ if pixels[x][y] == foreground:
+ pixels[x][y] = background
+ else:
+ pixels[x][y] = foreground
+ del pixels
+ for x in xrange(0, frame.get_width(), tile.get_width()):
+ for y in xrange(0, frame.get_height(), tile.get_height()):
+ frame.blit(tile, (x, y))
+ self.add_frame(frame)
+ self.location.bottom = self.ds.get_height() - 34