Changeset 429:8b047e74dfd1


Ignore:
Timestamp:
04/09/11 16:23:59 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Rebase:
30303238646161363735353235633466383464646535633432653163376131343834616139656331
Message:

Bump the player back into the world.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/player.py

    r427 r429  
    103103        self.init_pos()
    104104        return True
     105
     106    def fix_bounds(self, bounds):
     107        """Force the player back into the world."""
     108        if self.rect.bottom > bounds.bottom:
     109            self.rect.bottom = bounds.bottom - TILE_SIZE[1] - 5
     110        elif self.rect.top < bounds.top:
     111            self.rect.top = bounds.top + TILE_SIZE[1] + 10
     112        if self.rect.left < bounds.left:
     113            self.rect.left = bounds.left + TILE_SIZE[0]
     114        elif self.rect.right > bounds.right:
     115            self.rect.right = bounds.left - TILE_SIZE[0]
     116        # FIXME: Find clear tile
     117        # Hack -  bump vertical position up by 5 so we're not colliding
     118        # with the floor when we come back
     119        self.rect.bottom = self.rect.bottom - 5
     120        self.collide_rect.midbottom = self.rect.midbottom
     121        self.init_pos()
     122        self.set_image()
    105123
    106124    def update(self):
Note: See TracChangeset for help on using the changeset viewer.