Commits

Anonymous committed 47c1374

Added animation between levels.

Comments (0)

Files changed (2)

alchemymadness/main.py

 
     # Initialise level
     pot = potion.Potion()
-    pot.set_formula(10, 20, 30)
+    pot.set_formula(3, 5, 3)
 
     #TEST
     pot.add_color((0,0,255))
         for e in events:
             if e.type == KEYDOWN and e.key == K_SPACE:
                 pot.add_color((255,0,0))
-                screen.fill(pot.col, pot.rect)
-                rects.append(pot.rect)
             if e.type == QUIT or e.type == KEYDOWN and e.key == K_ESCAPE:
                 going = False
 
+        # Update potion
+        pot.update(time)
+        screen.fill(pot.col, pot.rect)
+        rects.append(pot.rect)
+
         screen.blit(background, (0,0))
         pygame.display.update(rects)
 

alchemymadness/potion.py

     col = (0,0,0)  # Current formula
     max_chems = 0  # Target number of chems
     start_y = 470
+    target_y = None
     rect = Rect(450, 470, 170, 113)
 
     def set_formula(self, r=0, g=0, b=0):
 
         # Update position
         n = self.chems / float(self.max_chems)
-        self.rect.y = self.start_y + self.rect.h*(1-n)
+        self.target_y = self.start_y + self.rect.h*(1-n)
 
     def get_score(self):
         """Returns a score based on accuracy of the formula."""
         pass
+
+    def update(self, time):
+        if self.target_y is not None:
+            self.rect.y -= 5*(time/1000.)
+            if self.rect.y < self.target_y:
+                self.rect.y = self.target_y
+                self.target_y = None