def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print "Cannot load image:", name
raise SystemExit, message
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, RLEACCEL)
return image, image.get_rect()
class Animal(pygame.sprite.Sprite):
def __init__(self, img, cX, cY, addx, addy):
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = load_image(img, -1)
screen = pygame.display.get_surface()
self.area = screen.get_rect()
self.rect.topleft = (cX-1)*50+addx, (cY-1)*50+addy
screen.blit(self.image, self.rect)
Примеры картинок вот:
Тигр грузится нормально, у медведя фон остается непрозрачным.