miss
authorFrank DeMarco <frank.s.demarco@gmail.com>
Sun, 28 Aug 2016 22:30:52 +0000 (18:30 -0400)
committerFrank DeMarco <frank.s.demarco@gmail.com>
Sun, 28 Aug 2016 22:31:05 +0000 (18:31 -0400)
HEAVENSlime.py
resource/Miss.png [new file with mode: 0644]
resource/Safe.png [new file with mode: 0644]

index 5bd778a..ba0feb1 100644 (file)
@@ -191,6 +191,16 @@ class Arena(Animation):
                 if self.ground.location.bottom <= ds.get_height():
                     self.shift_world(ds.get_height() - self.ground.location.bottom)
                     self.slime.stop()
+                elif self.slime.speed <= 0:
+                    for platform in self.platforms:
+                        if platform.passed and platform.collide(self.slime):
+                            self.slime.stop()
+                            self.shift_world(self.slime.location.bottom - platform.location.top + 1)
+                            if abs(self.slime.speed) < Platform.SAFETY_THRESHOLD:
+                                platform.set_safe()
+                            else:
+                                platform.set_miss()
+                            break
             ds.blit(self.background, (0, 0))
             self.ground.update()
             for platform in self.platforms:
@@ -323,7 +333,6 @@ class Slime(Sprite):
             self.speed -= self.GRAVITY
         Sprite.update(self)
 
-
 # TYPES
 # - rising away
 # - scrolling horizontally
@@ -331,14 +340,35 @@ class Slime(Sprite):
 # - springing up
 # - arcing swing
 # - blinking
+#
+# COLORS
+# - ff1c66 (rose)
+# - ffff66 (pale yellow)
+# - 78ff66 (pale green)
 
 class Platform(Sprite):
 
+    SAFETY_THRESHOLD = 3.75
+
     def __init__(self, parent, y):
         Sprite.__init__(self, parent)
+        self.passed = False
         self.load_from_path(self.get_resource("Platform.png"), True)
         self.iris = load(self.get_resource("Iris.png")).convert_alpha()
         self.y = y
         ds = self.get_display_surface()
         self.location.centerx = ds.get_rect().centerx
         self.location.centery = ds.get_height() - y
+
+    def set_safe(self):
+        self.clear_frames()
+        self.load_from_path(self.get_resource("Safe.png"), True)
+
+    def set_miss(self):
+        self.clear_frames()
+        self.load_from_path(self.get_resource("Miss.png"), True)
+
+    def update(self):
+        if self.location.top >= self.parent.slime.location.bottom:
+            self.passed = True
+        Sprite.update(self)
diff --git a/resource/Miss.png b/resource/Miss.png
new file mode 100644 (file)
index 0000000..19b69ac
Binary files /dev/null and b/resource/Miss.png differ
diff --git a/resource/Safe.png b/resource/Safe.png
new file mode 100644 (file)
index 0000000..623a79d
Binary files /dev/null and b/resource/Safe.png differ