disintegrate
authorFrank DeMarco <frank.s.demarco@gmail.com>
Sat, 31 May 2014 09:33:34 +0000 (18:33 +0900)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Sat, 31 May 2014 09:33:34 +0000 (18:33 +0900)
lake_of_heavenly_wind/LakeOfHeavenlyWind.py
resource/high-scores

index 97cacbe..cb6f7de 100644 (file)
@@ -795,7 +795,8 @@ class Paddles(GameChild):
                     for record in outgoing:
                         increase += record[1]
                         phage_total_x += record[0].get_center()[0]
-                        self.parent.rails.phages.remove(record[0])
+                        record[0].play(record[0].die)
+                        # self.parent.rails.phages.remove(record[0])
                     self.parent.pulp.score += increase * len(outgoing) * 10
                     if outgoing:
                         self.eliminate_phage_fx.play(float(phage_total_x) / \
@@ -1008,12 +1009,6 @@ class Rails(GameChild, list):
     def increase_spawn_rate(self):
         self.spawn_rate = self.spawn_nodeset.get_y(self.parent.wave)
         self.phage_step = self.step_nodeset.get_y(self.parent.wave)
-        # if self.spawn_rate < .065:
-        #     self.spawn_rate += self.spawn_rate * .3
-        #     self.phage_step += self.phage_step * .05
-        # else:
-        #     self.spawn_rate += 1e-3 / self.spawn_rate
-        #     self.phage_step += 3e-7 / self.phage_step
 
     def set_background(self):
         end = self.parent.link.background.location.bottom
@@ -1057,10 +1052,12 @@ class Rail(GameChild):
         return -1 if self.mirrored else 1
 
 
-class Phage(GameChild):
+class Phage(Animation):
+
+    TRANSPARENT_COLOR = (255, 0, 255)
 
     def __init__(self, parent, rail):
-        GameChild.__init__(self, parent)
+        Animation.__init__(self, parent, self.die, 50)
         self.rail = rail
         self.t = 0
         self.health = 1
@@ -1072,6 +1069,7 @@ class Phage(GameChild):
             for ii in xrange(2):
                 surface = Surface((size, size))
                 surface.fill([(255, 255, 255), (31, 31, 31)][(size + ii) % 2])
+                surface.set_colorkey(self.TRANSPARENT_COLOR)
                 segment.add_frame(surface)
             body.append(segment)
         center = self.parent.phage_step
@@ -1080,18 +1078,39 @@ class Phage(GameChild):
     def get_center(self):
         return self.body[0].location.midbottom
 
+    def die(self):
+        for segment in self.body:
+            alpha = segment.alpha - 48
+            if alpha <= 0:
+                print self.parent.phages
+                self.parent.phages.remove(self)
+                self.halt()
+                break
+            else:
+                for _ in xrange(10):
+                    w, h = segment.location.size
+                    segment.get_current_frame().set_at((randrange(0, w),
+                                                        randrange(0, h)),
+                                                       self.TRANSPARENT_COLOR)
+                segment.set_alpha(alpha)
+
     def update(self):
-        step = self.parent.phage_step * self.health
-        self.t += step
-        yr = self.yr
-        for ii, segment in sorted(enumerate(self.body), key=lambda b: b[0],
-                                  reverse=True):
-            dx = self.parent.deviation.get_y(self.t - ii * step) * \
-                 self.parent.stray * self.rail.get_modifier()
-            segment.location.center = self.rail.x + dx, \
-                                      yr[1] - (yr[1] - yr[0]) * (self.t - \
-                                                                 step * ii)
-            segment.update()
+        if not self.is_playing():
+            step = self.parent.phage_step * self.health
+            self.t += step
+            yr = self.yr
+            for ii, segment in sorted(enumerate(self.body), key=lambda b: b[0],
+                                      reverse=True):
+                dx = self.parent.deviation.get_y(self.t - ii * step) * \
+                     self.parent.stray * self.rail.get_modifier()
+                segment.location.center = self.rail.x + dx, \
+                                          yr[1] - (yr[1] - yr[0]) * (self.t - \
+                                                                     step * ii)
+                segment.update()
+        else:
+            for segment in self.body:
+                segment.update()
+        Animation.update(self)
 
 
 class Oracle(Animation):
index 7ca621a..58de7d8 100644 (file)
@@ -22,3 +22,4 @@
 1635
 1510
 1603
+1340