[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] A Basic Class



Mostly, I think, you just move sprites around by adjusting their rect property. Examples:

self.rect.top = self.rect.top + 5
self.rect.left = self.rect.left + 5

You should be able to subclass the sprite class and add methods that move the sprite around by adjusting it that way. Look at the rect portion of the manual for more info.

I've been playing around with Pygame recently just experimenting with how
the various intricacies of Pygame work.  I've read every tutorial I could
get my hands on.  Could anyone give me an example of a sprite/game object
class that would move the sprite up, down, left and right.  Something not
too complicated that I can build upon.  I've tried several times to create
my own, but to no avail.  If anyone can help, it would be greatly
appreciated.