Changeset 188:30a5f7cf670a


Ignore:
Timestamp:
04/06/11 19:02:38 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Message:

Hack'ish logic to move out of colliding with floors better

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/player.py

    r187 r188  
    9595            best_move = (0, 0)
    9696            clip_area = 0
    97             for rect in self._last_collide:
    98                 clip = rect.collide_rect.clip(self.collide_rect)
     97            for obj in self._last_collide:
     98                clip = obj.collide_rect.clip(self.collide_rect)
    9999                clip_area += clip.width * clip.height
     100                if (obj.floor or obj.block) and \
     101                        clip.width > obj.collide_rect.width /2 and \
     102                        self.collide_rect.bottom < obj.collide_rect.top + obj.collide_rect.height / 3:
     103                   delta = self.rect.bottom - self.collide_rect.bottom
     104                   self.collide_rect.bottom = obj.collide_rect.top - 1
     105                   self.rect.bottom = self.collide_rect.bottom + delta
     106                   break
    100107            min_area = clip_area
    101108            for attempt in [(0, 2), (2, 0), (-2, 0), (2, 2), (-2, 2)]:
    102109                clip_area = 0
    103                 for rect in self._last_collide:
     110                for obj in self._last_collide:
    104111                    cand_rect = self.collide_rect.move(attempt)
    105                     clip = rect.collide_rect.clip(cand_rect)
     112                    clip = obj.collide_rect.clip(cand_rect)
    106113                    clip_area += clip.width * clip.height
    107114                if clip_area < min_area:
Note: See TracChangeset for help on using the changeset viewer.