[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Odd problem with lists
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Odd problem with lists
- From: andrew baker <failrate@xxxxxxxxx>
- Date: Tue, 14 Dec 2004 21:02:21 -0800
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Wed, 15 Dec 2004 00:05:26 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=XOAreooY0ZYdWq453u0kwQ6CErrTr1Ehhbn1gXk+V1Hs/KYGHj19Jo8f/uCGwJPXFj1sCC3H3tSl88NH+fHm6EjLOMjpiFlir8agMRJN7ZefW4OYOVZYiC8CrF1d52WUUcm7ssW2haYht9+jLWT0FaUoczQ9ZIFLtV9nCj3O3BM=
- In-reply-to: <41BFC298.588928BE@rtccom.net>
- References: <41BFC298.588928BE@rtccom.net>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
What the heck are you doing copying images during your animation?
Forget that, it's wasteful and overcomplicated.
1. Make a list of images.
2. For each animation sequence (for example walking_left and
walking_right), make a list or tuple of indices in your list of images
(i.e. walking_left=(0,1,2,3)) that correspond to the cels in that
animation.
3.When the character state is (for example, walking to the left), then
anim_loop = walking_left.
4.You have a loop that every few cycles increments the animation
counter. Then player.image = anim_loop[animation_counter]
or... as in my code
if self.moving:
if self.frame_delay == DELAY:
self.frame_delay = 0
if self.frame_cel == len(self.current_strip)-1:
self.frame_cel = 0
else:
self.frame_cel += 1
else:
self.frame_delay += 1
if self.y_direction == up:
self.current_strip = self.up_strip
elif self.y_direction == down:
self.current_strip = self.down_strip
if self.x_direction == left:
self.current_strip = self.left_strip
elif self.x_direction == right:
self.current_strip = self.right_strip
self.image =
self.cel_group[self.current_strip[self.frame_cel]]
That should do you.
--
Andrew Ulysses Baker
"failrate"