Mercurial > rinkhals
changeset 234:ee1ac134022d
Fix drawing bug with multiframe animations
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 09:23:11 +0000 |
parents | d3d5352f5853 |
children | d0760fccce14 |
files | gamelib/gameboard.py |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gameboard.py Sat Sep 05 09:00:12 2009 +0000 +++ b/gamelib/gameboard.py Sat Sep 05 09:23:11 2009 +0000 @@ -163,25 +163,29 @@ us = [] x, y = self.vid.view.x, self.vid.view.y for anim in self.gameboard.animations[:]: - # We process removed animations 1st, so we redraw things correctly - if anim.removed: + if anim.updated or anim.removed: + # We flag that we need to redraw stuff undeneath the animation us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y, anim.irect.width, anim.irect.height)) - self.gameboard.animations.remove(anim) - # Flag the underlying tiles/sprites to be redrawn self.vid.alayer[anim.pos.y][anim.pos.x]=1 self.vid.updates.append(anim.pos.to_tuple()) + if anim.removed: + # Remove the animation from the draw loop + self.gameboard.animations.remove(anim) us.extend(self.vid.update(surface)) for anim in self.gameboard.animations: if anim.updated: anim.fix_pos(self.vid) - # setimage has happened + # setimage has happened, so redraw anim.irect.x = anim.rect.x - anim.shape.x anim.irect.y = anim.rect.y - anim.shape.y surface.blit(anim.image, (anim.irect.x - x, anim.irect.y - y)) anim.updated = 0 us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y, anim.irect.width, anim.irect.height)) + # This is enough, because sprite changes happen disjoint + # from the animation sequence, so we don't need to worry + # other changes forcing us to redraw the animation frame. return us def move_view(self, x, y):