diff options
author | davesilver <nibor123@gmail.com> | 2010-07-19 15:44:10 (GMT) |
---|---|---|
committer | davesilver <nibor123@gmail.com> | 2010-07-19 15:44:10 (GMT) |
commit | 020c58aeedc422c90c7855d111cc6f468f71098a (patch) | |
tree | ed833a692c6814baa226aa2f967dffaccb05ede7 /DrawableObjectTests/Spritesheet.py | |
parent | 48d87287c470a989ef77ffa7849459c88a8a65a0 (diff) |
Updating Tests
Diffstat (limited to 'DrawableObjectTests/Spritesheet.py')
-rwxr-xr-x | DrawableObjectTests/Spritesheet.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/DrawableObjectTests/Spritesheet.py b/DrawableObjectTests/Spritesheet.py index a16226c..06753aa 100755 --- a/DrawableObjectTests/Spritesheet.py +++ b/DrawableObjectTests/Spritesheet.py @@ -7,23 +7,25 @@ class Spritesheet: This class can be used to seporate images from the sprite sheet
"""
def __init__(self, filename):
- self.sheet = pygame.image.load(filename)#.convert()
+ self.sheet = pygame.image.load(filename).convert()
- def imgat(self, rect):
+ def imgat(self, rect, myColorKey = None):
rect = pygame.Rect(rect)
- image = pygame.Surface(rect.size)#.convert()
+ image = pygame.Surface(rect.size).convert()
+ if myColorKey = None: myColorKey = images.get_at(0,0)
+ image.set_colorkey(myColorKey)
image.blit(self.sheet, (0, 0), rect)
return image
- def imgsat(self, rects):
+ def imgsat(self, rects, myColorKey = None):
imgs = []
for rect in rects:
- imgs.append(self.imgat(rect))
+ imgs.append(self.imgat(rect), myColorKey)
return imgs
- def img_extract( self, cols, rows, width, height ):
+ def img_extract( self, cols, rows, width, height, myColorKey = None):
rect_list = []
for y in range(0, rows):
for x in range(0, cols):
- rect_list.append( (width*x, height*y, width, height) )
+ rect_list.append( (width*x, height*y, width, height, myColorKey) )
return self.imgsat( rect_list)
\ No newline at end of file |