[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Problems with moving animated images
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Problems with moving animated images
- From: "Brian Fisher" <brian@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 8 Apr 2006 20:07:46 -0700
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Sat, 08 Apr 2006 23:07:50 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TKKCJ2urfpbI2ORzvLPU3HiNJY6LtfIg2EI1zT8j5VrUjJjLjQl8e5az5zFkfKWs3jlVthUdRtbEmEkXn4kutI2S0PBlLL1KY/JiBn/RTr9KZzSWF+A1mrhV2G4IMTpc672x8K2Ot1Pi8ElMFKf3x+i+QD7oYpSodAI0l5/YTIU=
- In-reply-to: <001901c65b38$25997cf0$b3baba50@hercules>
- References: <001901c65b38$25997cf0$b3baba50@hercules>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
On 4/8/06, Juha <sj.m@xxxxxxxxxxx> wrote:
> I forgot to show the sprite's move method, so here goes:
>
> def move(self, pos):
> self.frect = self.frect.move(pos.getX(), pos.getY())
> self.rect = self.rect.move(pos.getX(), pos.getY())
> x = self.pos.getX() + pos.getX()
> y = self.pos.getY() + pos.getY()
> self.pos.set(x, y)
>
Looks like you are modifying the src rect (self.frect) when moving, I
don't think you want to do that (the src rect should be relative to
the large surface, not relative to the screen)
also, you don't need to use a rect for the destination position of the
blit - a 2 element position is all you need (surface.blit ignores the
destination rect width & height if you pass a rect)