Mercurial > pygame-tutorial-slides
changeset 132:cbfbaa153991
created
| author | Radomir Dopieralski |
|---|---|
| date | Mon, 18 Jun 2012 20:37:35 +0200 |
| parents | 8b3f7438b17a |
| children | db5fee4aac7f |
| files | docs/003%2F003.py |
| diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/003%2F003.py Mon Jun 18 20:37:35 2012 +0200 @@ -0,0 +1,11 @@ +class HeroSprite(pygame.sprite.Sprite): + def move(self, (dx, dy)): + self.animations.append(self.animation_walk((dx, dy))) + + def animation_walk(self, (dx, dy)): + facing = FACING[dx, dy] + for step in xrange(8): + self.image = self.spritesheet[facing + step * 4 + 4] + self.rect.move_ip(dx * 4, dy * 4) + yield + self.image = self.spritesheet[facing]
