Mercurial > skaapsteker
changeset 200:4e3f9cb49489
Fix bug in jump to tile top logic
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Wed, 06 Apr 2011 22:26:17 +0200 |
parents | 2b4de243e9f2 |
children | e27c45d38605 |
files | skaapsteker/sprites/player.py |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/skaapsteker/sprites/player.py Wed Apr 06 22:17:59 2011 +0200 +++ b/skaapsteker/sprites/player.py Wed Apr 06 22:26:17 2011 +0200 @@ -93,16 +93,21 @@ # surface best_move = (0, 0) clip_area = 0 - for obj in self._last_collide: + for obj in self._last_collide[:]: + if not obj.collide_rect.colliderect(self.collide_rect): + # Prune stale objects from the list + self._last_collide.remove(obj) + continue clip = obj.collide_rect.clip(self.collide_rect) clip_area += clip.width * clip.height if (obj.floor or obj.block) and \ - clip.width > obj.collide_rect.width /2 and \ - self.collide_rect.bottom < obj.collide_rect.top + obj.collide_rect.height / 3: + clip.width > TILE_SIZE[0] / 2 and \ + self.collide_rect.bottom < obj.collide_rect.top + TILE_SIZE[1] / 3: delta = self.rect.bottom - self.collide_rect.bottom self.collide_rect.bottom = obj.collide_rect.top - 1 self.rect.bottom = self.collide_rect.bottom + delta - break + self.init_pos() + return # Jump out of this case min_area = clip_area for attempt in [(0, 2), (2, 0), (-2, 0), (2, 2), (-2, 2)]: clip_area = 0