Mercurial > rinkhals
diff gamelib/gameboard.py @ 380:1586eccdefe4
Ripped out legacy animation infrastructure in favour of layered sprites.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 25 Oct 2009 10:56:01 +0000 |
parents | a8a7ada27fa2 |
children | 7a58dadfd251 |
line wrap: on
line diff
--- a/gamelib/gameboard.py Sat Oct 24 21:43:15 2009 +0000 +++ b/gamelib/gameboard.py Sun Oct 25 10:56:01 2009 +0000 @@ -253,44 +253,9 @@ def paint(self, surface): self.vid.paint(surface) - # Blit animation frames on top of the drawing - x, y = self.vid.view.x, self.vid.view.y - for anim in self.gameboard.animations: - anim.fix_pos(self.vid) - 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)) - # We don't store anim._irect, since we only update anims if the - # image changes, which kills irect def update(self, surface): - us = [] - x, y = self.vid.view.x, self.vid.view.y - for anim in self.gameboard.animations[:]: - if (anim.updated or anim.removed) and \ - self.gameboard.in_bounds(anim.pos): - # We flag that we need to redraw stuff undeneath the animation - anim.irect.x = anim.rect.x - anim.shape.x - anim.irect.y = anim.rect.y - anim.shape.y - us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y, - anim.irect.width, anim.irect.height)) - 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: - # setimage has happened, so redraw - anim.updated = 0 - anim.fix_pos(self.vid) - if self.gameboard.in_bounds(anim.pos): - surface.blit(anim.image, (anim.irect.x - x, anim.irect.y - y)) - # 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 + return self.vid.update(surface) def move_view(self, x, y): self.vid.view.move_ip((x, y)) @@ -337,7 +302,6 @@ self.chickens = set() self.foxes = set() self.buildings = [] - self.animations = [] self.cash = 0 self.eggs = 0 self.days = 0 @@ -826,8 +790,7 @@ self.foxes = set() # Remove all the foxes def run_animations(self): - for anim in self.animations: - anim.animate() + # For legacy. if self.toolbar.anim_clear_tool: self.toolbar.clear_tool()