bulb
authorFrank DeMarco <frank.s.demarco@gmail.com>
Tue, 20 May 2014 23:41:26 +0000 (08:41 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Tue, 20 May 2014 23:41:26 +0000 (08:41 +0900)
lake_of_heavenly_wind/LakeOfHeavenlyWind.py

index 02ea8d9..75bd78f 100644 (file)
@@ -49,6 +49,8 @@ class GameScreen(GameChild):
         GameChild.__init__(self, parent)
         self.display_surface = self.get_display_surface()
         self.set_background()
+        self.pulp = Pulp(self)
+        self.link = Link(self)
         self.paddles = Paddles(self)
 
     def set_background(self):
@@ -73,6 +75,60 @@ class GameScreen(GameChild):
         if self.active:
             self.display_surface.blit(self.background, (0, 0))
             self.paddles.update()
+            self.pulp.update()
+            self.link.update()
+
+
+class Pulp(GameChild, Surface):
+
+    def __init__(self, parent):
+        GameChild.__init__(self, parent)
+        self.display_surface = self.get_display_surface()
+        Surface.__init__(self, (self.display_surface.get_width(), 112))
+        self.background = Surface(self.get_size())
+        self.background.fill((255, 255, 255))
+        tile = Surface((16, 16))
+        tile.fill((255, 255, 255))
+        tile.set_at((4, 4), (31, 31, 31))
+        tile.set_at((12, 12), (31, 31, 31))
+        for x in xrange(0, self.background.get_width(), tile.get_width()):
+            for y in xrange(0, self.background.get_height(), tile.get_height()):
+                self.background.blit(tile, (x, y))
+
+    def update(self):
+        self.blit(self.background, (0, 0))
+        self.display_surface.blit(self, (0, 0))
+
+
+class Link(GameChild):
+
+    def __init__(self, parent):
+        GameChild.__init__(self, parent)
+        self.display_surface = self.get_display_surface()
+        self.background = Sprite(self, 500)
+        tile = Surface((2, 2))
+        for x in xrange(tile.get_width()):
+            for y in xrange(tile.get_height()):
+                tile.set_at((x, y), [(255, 255, 0), (228, 228, 228)][(x + y) % 2])
+        for jj in xrange(3):
+            frame = Surface((self.display_surface.get_width(), 24))
+            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))
+            for ii, x in enumerate(xrange(-4, frame.get_width(), 16)):
+                colors = [(63, 255, 63), (240, 240, 63), (191, 31, 220)]
+                primary_color = colors[(ii - jj) % 3]
+                secondary_color = colors[(ii - jj + 1) % 3]
+                frame.fill(primary_color, (x, 0, 8, 3))
+                frame.fill(secondary_color, (x + 2, 1, 4, 2))
+                frame.fill(primary_color, (x, frame.get_height() - 3, 8, 3))
+                frame.fill(secondary_color, (x + 2, frame.get_height() - 3, 4,
+                                             2))
+            self.background.add_frame(frame)
+        self.background.location.top = self.parent.pulp.get_rect().bottom
+
+    def update(self):
+        self.background.update()
 
 
 class Paddles(GameChild):
@@ -153,7 +209,7 @@ class Paddles(GameChild):
     def set_paddles(self):
         image = load(self.get_resource("image", "paddle")).convert_alpha()
         self.paddle_length = image.get_width()
-        margin = 240
+        margin = (self.get_display_surface().get_width() / 2) - self.paddle_length
         surface = Surface((image.get_width() * 2 + margin, image.get_height()))
         key = (255, 0, 255)
         surface.fill(key)
@@ -258,18 +314,19 @@ class Paddles(GameChild):
             self.paddles.move(ds.get_width())
         elif self.paddles.location.right > ds.get_width():
             self.paddles.move(-ds.get_width())
+        self.graticule.move(dy=-14)
         for location in self.graticule.locations:
             if location.right < 0:
                 location.move_ip(ds.get_width(), 0)
             elif location.right > ds.get_width():
                 location.move_ip(-ds.get_width(), 0)
-            if location.top < 0:
-                location.move_ip(0, ds.get_height() - 20)
+            if location.top < self.parent.link.background.rect.bottom:
+                location.move_ip(0, ds.get_height() - \
+                                 self.parent.link.background.rect.bottom - 32)
         self.lattice.move(-.5)
         if self.lattice.location.right < ds.get_rect().right:
             self.lattice.move(ds.get_rect().right - \
                               self.lattice.location.right + 16)
-        self.graticule.move(dy=-14)
         self.lattice.update()
         self.graticule.update()
         for mine in self.mines: