floor
authorFrank DeMarco <frank.s.demarco@gmail.com>
Mon, 25 Aug 2014 15:48:36 +0000 (00:48 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Mon, 25 Aug 2014 15:48:36 +0000 (00:48 +0900)
README
resource/img/Maltese/4.png
resource/img/Parasitic-Manure-Crabs.png [new file with mode: 0644]
shaken_and_spit_out/SSO.py

diff --git a/README b/README
index 09bf6a3..f0a7955 100644 (file)
--- a/README
+++ b/README
@@ -11,7 +11,7 @@ attempt PSPPIT, continual establishment of foundation in the firmament
 
 Instructions
 ~~~~~~~~~~~~
-Predict the path of an agitated particle by placing two points
+Predict the path of the particle by placing two points
 
 Keys
 ~~~~
index 78b1be0..a24192f 100644 (file)
Binary files a/resource/img/Maltese/4.png and b/resource/img/Maltese/4.png differ
diff --git a/resource/img/Parasitic-Manure-Crabs.png b/resource/img/Parasitic-Manure-Crabs.png
new file mode 100644 (file)
index 0000000..b177988
Binary files /dev/null and b/resource/img/Parasitic-Manure-Crabs.png differ
index e5657d4..43d8d27 100644 (file)
@@ -21,7 +21,7 @@ class SSO(Game):
         # 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 = []
@@ -32,6 +32,7 @@ class SSO(Game):
     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))).\
@@ -48,6 +49,7 @@ class SSO(Game):
     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))
 
@@ -63,7 +65,8 @@ class Title(GameChild):
         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:
@@ -181,3 +184,30 @@ class Preface(GameChild, Surface):
         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