# HG changeset patch # User Neil Muller # Date 1302366239 -7200 # Node ID 8b047e74dfd181893c92d01c044c900701d08a88 # Parent 6a8f98335a53a97a7f3d1a88edbfb187de9907d8 Bump the player back into the world. diff -r 6a8f98335a53 -r 8b047e74dfd1 skaapsteker/sprites/player.py --- 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