Changeset 234:ee1ac134022d


Ignore:
Timestamp:
Sep 5, 2009, 9:23:11 AM (11 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@235
Message:

Fix drawing bug with multiframe animations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gamelib/gameboard.py

    r232 r234  
    164164        x, y = self.vid.view.x, self.vid.view.y
    165165        for anim in self.gameboard.animations[:]:
    166             # We process removed animations 1st, so we redraw things correctly
    167             if anim.removed:
     166            if anim.updated or anim.removed:
     167                # We flag that we need to redraw stuff undeneath the animation
    168168                us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y,
    169169                    anim.irect.width, anim.irect.height))
    170                 self.gameboard.animations.remove(anim)
    171                 # Flag the underlying tiles/sprites to be redrawn
    172170                self.vid.alayer[anim.pos.y][anim.pos.x]=1
    173171                self.vid.updates.append(anim.pos.to_tuple())
     172            if anim.removed:
     173                # Remove the animation from the draw loop
     174                self.gameboard.animations.remove(anim)
    174175        us.extend(self.vid.update(surface))
    175176        for anim in self.gameboard.animations:
    176177            if anim.updated:
    177178                anim.fix_pos(self.vid)
    178                 # setimage has happened
     179                # setimage has happened, so redraw
    179180                anim.irect.x = anim.rect.x - anim.shape.x
    180181                anim.irect.y = anim.rect.y - anim.shape.y
     
    183184                us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y,
    184185                    anim.irect.width, anim.irect.height))
     186                # This is enough, because sprite changes happen disjoint
     187                # from the animation sequence, so we don't need to worry
     188                # other changes forcing us to redraw the animation frame.
    185189        return us
    186190
Note: See TracChangeset for help on using the changeset viewer.