Mercurial > skaapsteker
changeset 429:8b047e74dfd1
Bump the player back into the world.
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 18:23:59 +0200 |
parents | 6a8f98335a53 |
children | 25efc74ac19c |
files | skaapsteker/sprites/player.py |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/skaapsteker/sprites/player.py Sat Apr 09 18:23:59 2011 +0200 +++ b/skaapsteker/sprites/player.py Sat Apr 09 18:23:59 2011 +0200 @@ -103,6 +103,24 @@ self.init_pos() return True + def fix_bounds(self, bounds): + """Force the player back into the world.""" + if self.rect.bottom > bounds.bottom: + self.rect.bottom = bounds.bottom - TILE_SIZE[1] - 5 + elif self.rect.top < bounds.top: + self.rect.top = bounds.top + TILE_SIZE[1] + 10 + if self.rect.left < bounds.left: + self.rect.left = bounds.left + TILE_SIZE[0] + elif self.rect.right > bounds.right: + self.rect.right = bounds.left - TILE_SIZE[0] + # FIXME: Find clear tile + # Hack - bump vertical position up by 5 so we're not colliding + # with the floor when we come back + self.rect.bottom = self.rect.bottom - 5 + self.collide_rect.midbottom = self.rect.midbottom + self.init_pos() + self.set_image() + def update(self): self._touching_actionables = [] v_x, v_y = self.velocity