Mercurial > rinkhals
comparison 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 |
comparison
equal
deleted
inserted
replaced
371:c39e7d33ac82 | 372:90abd39e6c3c |
---|---|
269 | 269 |
270 def update(self, surface): | 270 def update(self, surface): |
271 us = [] | 271 us = [] |
272 x, y = self.vid.view.x, self.vid.view.y | 272 x, y = self.vid.view.x, self.vid.view.y |
273 for anim in self.gameboard.animations[:]: | 273 for anim in self.gameboard.animations[:]: |
274 if anim.updated or anim.removed: | 274 if (anim.updated or anim.removed) and \ |
275 self.gameboard.in_bounds(anim.pos): | |
275 # We flag that we need to redraw stuff undeneath the animation | 276 # We flag that we need to redraw stuff undeneath the animation |
277 anim.irect.x = anim.rect.x - anim.shape.x | |
278 anim.irect.y = anim.rect.y - anim.shape.y | |
276 us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y, | 279 us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y, |
277 anim.irect.width, anim.irect.height)) | 280 anim.irect.width, anim.irect.height)) |
278 self.vid.alayer[anim.pos.y][anim.pos.x]=1 | 281 self.vid.alayer[anim.pos.y][anim.pos.x]=1 |
279 self.vid.updates.append(anim.pos.to_tuple()) | 282 self.vid.updates.append(anim.pos.to_tuple()) |
280 if anim.removed: | 283 if anim.removed: |
281 # Remove the animation from the draw loop | 284 # Remove the animation from the draw loop |
282 self.gameboard.animations.remove(anim) | 285 self.gameboard.animations.remove(anim) |
283 us.extend(self.vid.update(surface)) | 286 us.extend(self.vid.update(surface)) |
284 for anim in self.gameboard.animations: | 287 for anim in self.gameboard.animations: |
285 if anim.updated: | 288 if anim.updated: |
289 # setimage has happened, so redraw | |
290 anim.updated = 0 | |
286 anim.fix_pos(self.vid) | 291 anim.fix_pos(self.vid) |
287 # setimage has happened, so redraw | 292 if self.gameboard.in_bounds(anim.pos): |
288 anim.irect.x = anim.rect.x - anim.shape.x | 293 surface.blit(anim.image, (anim.irect.x - x, anim.irect.y - y)) |
289 anim.irect.y = anim.rect.y - anim.shape.y | |
290 surface.blit(anim.image, (anim.irect.x - x, anim.irect.y - y)) | |
291 anim.updated = 0 | |
292 us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y, | |
293 anim.irect.width, anim.irect.height)) | |
294 # This is enough, because sprite changes happen disjoint | 294 # This is enough, because sprite changes happen disjoint |
295 # from the animation sequence, so we don't need to worry | 295 # from the animation sequence, so we don't need to worry |
296 # other changes forcing us to redraw the animation frame. | 296 # other changes forcing us to redraw the animation frame. |
297 return us | 297 return us |
298 | 298 |
735 | 735 |
736 equipment = equipment_cls() | 736 equipment = equipment_cls() |
737 | 737 |
738 def do_equip(chicken, update_button=None): | 738 def do_equip(chicken, update_button=None): |
739 # Try to equip the chicken | 739 # Try to equip the chicken |
740 if self.cash < equipment.buy_price(): | |
741 return False | |
740 if equipment.place(chicken): | 742 if equipment.place(chicken): |
741 self.add_cash(-equipment.buy_price()) | 743 self.add_cash(-equipment.buy_price()) |
742 chicken.equip(equipment) | 744 chicken.equip(equipment) |
743 if update_button: | 745 if update_button: |
744 update_button(chicken) | 746 update_button(chicken) |
745 return False | 747 return False |
746 | 748 |
747 chicken = self.get_outside_chicken(tile_pos) | 749 chicken = self.get_outside_chicken(tile_pos) |
748 if self.cash < equipment.buy_price(): | |
749 return | |
750 if chicken is None: | 750 if chicken is None: |
751 building = self.get_building(tile_pos) | 751 building = self.get_building(tile_pos) |
752 if building is None: | 752 if building is None: |
753 return | 753 return |
754 # Bounce through open dialog once more | 754 # Bounce through open dialog once more |