Mercurial > rinkhals
diff gamelib/gameboard.py @ 372:90abd39e6c3c 1.0.x
Merge in post-pyweek fixes (r359:371).
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Tue, 13 Oct 2009 20:28:48 +0000 |
parents | e61f95503461 |
children |
line wrap: on
line diff
--- a/gamelib/gameboard.py Tue Oct 13 20:12:06 2009 +0000 +++ b/gamelib/gameboard.py Tue Oct 13 20:28:48 2009 +0000 @@ -271,8 +271,11 @@ us = [] x, y = self.vid.view.x, self.vid.view.y for anim in self.gameboard.animations[:]: - if anim.updated or anim.removed: + 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 @@ -282,15 +285,12 @@ 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) + if anim.updated: # 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)) + 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. @@ -737,6 +737,8 @@ def do_equip(chicken, update_button=None): # Try to equip the chicken + if self.cash < equipment.buy_price(): + return False if equipment.place(chicken): self.add_cash(-equipment.buy_price()) chicken.equip(equipment) @@ -745,8 +747,6 @@ return False chicken = self.get_outside_chicken(tile_pos) - if self.cash < equipment.buy_price(): - return if chicken is None: building = self.get_building(tile_pos) if building is None: