pygamegsoc12 / alchemymadness / blocks.py

Diff from to

alchemymadness/blocks.py

 from itertools import izip, chain
 
 import pygame
-from pygame.sprite import DirtySprite
 
 import resources
 import layout
+from sprite import MaskedSprite
 
-class Block(DirtySprite):
+class Block(MaskedSprite):
     """ A single block.
     """
     rect = layout.Main.block_rect
-    changed = False # True if sprite image need to be regenerated
 
     def __init__(self, color, *groups):
-        """
-            color - (r,g,b) tuple
-        """
-        super(Block, self).__init__(*groups)
-        self._image = pygame.Surface(self.rect.size) # Sprite image
+        super(Block, self).__init__(color, *groups)
         self.t_image = resources.block
-        self._color = color  # Block color
-        self.changed = True
-        self.dirty = 1
-
-    @property
-    def image(self):
-        if self.changed:
-            self._image = self.t_image.copy()
-            self._image.fill(self._color, special_flags=pygame.locals.BLEND_RGBA_MULT)
-        return self._image
-
-    @property
-    def color(self):
-        return self._color
-
-    @color.setter
-    def color(self, value):
-        self._color = value
-        self.changed = True
-
 
     def grid_pos(self, pos, grid_rect):
         """ set the rect for the given (x,y) grid pos
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.