1. pygame
  2. pygame
  3. pygamegsoc12

Source

pygamegsoc12 / alchemymadness / potion.py

Diff from to

File alchemymadness/potion.py

  • Ignore whitespace
           col: tuple containing rgb colour.
 
         """
-        self.chems += 1
-        n = ((self.chems-1) / float(self.chems))
-        self.mix_color(col, 1-n)
-#        self.target_col = (self.color[0] * n, self.color[1] * n, self.color[2] * n)
-#        self.target_col = (self.target_col[0] + col[0]/float(self.chems),
-#                           self.target_col[1] + col[1]/float(self.chems),
-#                           self.target_col[2] + col[2]/float(self.chems))
-#        self.diff_col = ((self.target_col[0] - self.color[0]),
-#                         (self.target_col[1] - self.color[1]),
-#                         (self.target_col[2] - self.color[2]))
-        # Update position
-        n = self.chems / float(self.max_chems)
-        self.target_y = self.mask_rect.h*(1-n)
+        if self.chems < self.max_chems:
+            self.chems += 1
+            self.mix_color(col, 1/float(self.chems))
+            r = self.mask_rect.copy()
+            n = self.chems / float(self.max_chems)
+            r.y = self.mask_rect.h*(1-n)
+            self.move_mask(r)
 
     def get_score(self):
         """Returns a score based on accuracy of the formula."""
         pass
-
-    def update(self, time):
-        #super(Potion, self).update(time)
-        # Move rect smoothly
-        if self.target_y is not None:
-            self.dirty = 1
-            self.mask_rect.y -= 5*(time/1000.)
-            if self.mask_rect.y < self.target_y:
-                self.mask_rect.y = self.target_y
-                self.target_y = None
-        # Lerp colours
-        if self.target_col is not None:
-            self.changed = True
-            diff = (self.diff_col[0] * (time/500.),
-                    self.diff_col[1] * (time/500.),
-                    self.diff_col[2] * (time/500.))
-            col = [self.color[0] + diff[0], self.color[1] + diff[1],
-                   self.color[2] + diff[2]]
-            for i in range(3):
-                if diff[i] > 0:
-                    col[i] = min(col[i], self.target_col[i])
-                else:
-                    col[i] = max(col[i], self.target_col[i])
-
-            self.color = tuple(col)
-            if self.color == self.target_col:
-                self.target_col = None