def load_mask(filename, give_orig=False): if filename in masks: if give_orig: return masks[filename] else: return masks[filename].copy() # first try to load the sprite from the sprite folder, fall back to our zipped sprites # this allows users to override sprites, and makes testing/developing easier try: bitmask = mask.from_image(spritesfolder + filename + ".png") except: sprites = zipfile.ZipFile(spriteszip, "r") spritefile = cStringIO.StringIO(sprites.open("sprites/" + filename + ".png", "r").read()) bitmask = mask.from_image(spritefile) spritefile.close() masks[filename] = bitmask if give_orig: return bitmask else: return bitmask.copy()
def load_mask(filename, give_orig=False): if filename in masks: if give_orig: return masks[filename] else: return masks[filename].copy() bitmask = mask.from_image(filename) masks[filename] = bitmask if give_orig: return bitmask else: return bitmask.copy()