[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] sprite groups and tilesheets
- To: pygame-users@xxxxxxxx
- Subject: [pygame] sprite groups and tilesheets
- From: Michael Fiano <michael.fiano@xxxxxxxxx>
- Date: Mon, 10 Nov 2008 23:52:06 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 10 Nov 2008 23:46:16 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:x-mailer:mime-version:content-type :content-transfer-encoding; bh=kJFjP50ZXalK0f2J8tgfPGzMWtr24r4HMCH3tFrW4SY=; b=r9zCb6KMwZria8aS/8tBcVUqmM7zT0jycgpkMsppxaM2n+FvkvtcBsknXbzeT3AcpK fOOKTlGFe1usUQbOC4Ww2qbTVrGDJTcDcblGHnUblJyOHAZlURtHSxPw0mNQWvNMccUl +uIXWzs0BnSCEbSvth/+gTsmnqnBhEcCKk+J4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:x-mailer:mime-version:content-type :content-transfer-encoding; b=ayubLtVHqya9B2u29zysq80Gw5cS4sV2Raw+jFnSpWAyAHyppl3Ed6xd1zlSIR385t nPcjosFoJtyOdntlMlEgr9zFeUjllDcw0I7KjCcpdMXgAKebG5k+t3sC5n6TQG4r5V3e BkwhbnE251Lag93HH7Q5jXrUnYfvPIWk9tUa4=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
I am having problems adding my player sprite to a sprite group since
self.image needs a surface, though it is a list of animation frames for the player in my code and I can't
figure out what I need to do. Can anybody give me some pointers? Thanks.
self.image = load_sprite('player.png')
class load_sprite:
def __init__(self, filename):
self.sheet = pygame.image.load(os.path.join('data', 'graphics', filename))
def imgat(self, rect, colorkey = None):
rect = Rect(rect)
image = pygame.Surface(rect.size).convert()
image.blit(self.sheet, (0, 0), rect)
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0, 0))
image.set_colorkey(colorkey, RLEACCEL)
return image
def imgsat(self, rects, colorkey = None):
imgs = []
for rect in rects:
imgs.append(self.imgat(rect, colorkey))
return imgs