stationary electric
authorFrank DeMarco <frank.s.demarco@gmail.com>
Fri, 25 Apr 2014 21:07:57 +0000 (06:07 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Fri, 25 Apr 2014 21:07:57 +0000 (06:07 +0900)
config
scale_sieve/ScaleSieve.py

diff --git a/config b/config
index a4b2dd0..79dc918 100644 (file)
--- a/config
+++ b/config
@@ -5,6 +5,6 @@ dimensions = 420, 700
 quit = K_ESCAPE
 
 [interpolate]
-scale = C 0.0 10.0, 600.0 90.0
+scale = C 0.0 10.0, 850.0 110.0
 shift = C 0.0 0.0, 1300.0 4.7, 2000.0 6.0
-shift-2 = C 0.0 0.0, 840.0 4.2, 2000.0 6.0
+shift-2 = C 0.0 0.0, 840.0 4.2, 2000.0 8.0
index e5d9f16..58611cc 100644 (file)
@@ -85,12 +85,13 @@ class Sieve(Strip):
     def __init__(self, parent):
         Strip.__init__(self, parent)
         self.location.center = self.display_surface.get_rect().center
+        self.electric = Electric(self)
 
     def add_frames(self):
         bar_locations = []
         x = 0
         nodeset = self.get_game().interpolator.get_nodeset("scale")
-        while x < 600:
+        while x < nodeset[-1].x:
             bar_locations.append(x)
             x += nodeset.get_y(x, natural=True)
         surface = Surface((x, 30))
@@ -98,21 +99,39 @@ class Sieve(Strip):
         surface.fill(transparent_color)
         surface.set_colorkey(transparent_color)
         frames = surface, surface.copy()
-        background_colors = (255, 255, 0), (0, 0, 213)
-        divider_colors = (0, 255, 0), (153, 0, 204)
+        colors = (0, 255, 0), (153, 0, 204)
+        for x in bar_locations:
+            for ii, frame in enumerate(frames):
+                frame.fill(colors[ii], (x, 0, 3, surface.get_height()))
+                frame.fill(colors[ii - 1], (x + 1, 1, 1,
+                                            surface.get_height() - 2))
+        for frame in frames:
+            self.add_frame(frame)
+
+    def update(self):
+        self.electric.location.centery = self.location.centery
+        self.electric.update()
+        Strip.update(self)
+
+
+class Electric(Sprite):
+
+    def __init__(self, parent):
+        Sprite.__init__(self, parent)
+        self.display_surface = self.get_display_surface()
+        self.add_frames()
+
+    def add_frames(self):
+        surface = Surface((self.display_surface.get_width(),
+                           self.parent.location.h - 10))
+        frames = surface, surface.copy()
+        colors = (255, 255, 0), (100, 89, 213)
         pixel_arrays = PixelArray(frames[0]), PixelArray(frames[1])
-        bw = 5
         for x in xrange(len(pixel_arrays[0])):
-            for y in xrange(bw, len(pixel_arrays[0][0]) - bw):
-                pixel_arrays[0][x][y] = background_colors[(y + x) % 2]
-                pixel_arrays[1][x][y] = background_colors[(y + x + 1) % 2]
+            for y in xrange( len(pixel_arrays[0][0])):
+                pixel_arrays[0][x][y] = colors[(y + x) % 2]
+                pixel_arrays[1][x][y] = colors[(y + x + 1) % 2]
         for pixels in pixel_arrays:
             del pixels
-        x = 0
-        for x in bar_locations:
-            for ii, frame in enumerate(frames):
-                frame.fill(divider_colors[ii], (x, 0, 3, surface.get_height()))
-                frame.fill(divider_colors[ii - 1], (x + 1, 1, 1,
-                                                    surface.get_height() - 2))
         for frame in frames:
             self.add_frame(frame)