cloud
authorFrank DeMarco <frank.s.demarco@gmail.com>
Mon, 25 Aug 2014 17:39:53 +0000 (02:39 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Mon, 25 Aug 2014 17:39:53 +0000 (02:39 +0900)
resource/img/Safire-Translimitter.png [new file with mode: 0644]
shaken_and_spit_out/SSO.py

diff --git a/resource/img/Safire-Translimitter.png b/resource/img/Safire-Translimitter.png
new file mode 100644 (file)
index 0000000..e76d537
Binary files /dev/null and b/resource/img/Safire-Translimitter.png differ
index 43d8d27..4767b55 100644 (file)
@@ -33,6 +33,7 @@ class SSO(Game):
         Game.set_children(self)
         self.title = Title(self)
         self.floor = Floor(self)
+        self.cloud = Cloud(self)
 
     def set_random_background(self):
         index = choice(list(set(range(len(self.backgrounds))).\
@@ -49,6 +50,7 @@ class SSO(Game):
     def update(self):
         self.get_screen().blit(self.background, (0, 0))
         self.title.update()
+        self.cloud.update()
         self.floor.update()
         # self.get_screen().fill((0, 0, 0))
         # self.get_screen().blit(self.message, (100, 100))
@@ -211,3 +213,40 @@ class Floor(Sprite):
                     frame.blit(tile, (x, y))
             self.add_frame(frame)
         self.location.bottom = self.ds.get_height() - 34
+
+
+class Cloud(GameChild):
+
+    def __init__(self, parent):
+        GameChild.__init__(self, parent)
+        self.ds = self.get_display_surface()
+        layers = self.layers = []
+        base = load(self.get_resource("image", "cloud")).convert_alpha()
+        for ii in xrange(3):
+            layer = Sprite(self)
+            frame = base.copy()
+            pixels = PixelArray(frame)
+            for x in xrange(len(pixels)):
+                for y in xrange(len(pixels[0])):
+                    color = Color(*base.unmap_rgb(pixels[x][y]))
+                    h, s, l, a = color.hsla
+                    color.hsla = int(h), int(s), int(l), \
+                                 int(a * (.95 * (1 - ii * .15)))
+                    pixels[x][y] = color
+            del pixels
+            layer.add_frame(frame)
+            layer.move(ii * 3)
+            layer.location.bottom = self.ds.get_height()
+            layers.append(layer)
+
+    def update(self):
+        fr = self.get_game().floor.location
+        ds = self.ds
+        ds.set_clip(fr.topleft, (ds.get_width(), ds.get_height() - fr.top))
+        for ii, layer in enumerate(self.layers):
+            layer.move(dy=1 + (ii * .5))
+            if layer.location.top > fr.top:
+                layer.location.bottom = ds.get_height() + layer.location.top - \
+                                        fr.top
+            layer.update()
+        ds.set_clip(None)