animated_sprite.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pyclimber 作者: manixaist 项目源码 文件源码
def basic_bounds_containment(self, tile_map):
        """Contains the sprite to the player bounds"""
        # Bounds check on bottom edge
        if self.rect.bottom > tile_map.player_bounds_rect.bottom:
            self.rect.bottom = tile_map.player_bounds_rect.bottom
            self.dy = 0.0
            self.falling = False

        # Left/Right bounds containment check
        # RIGHT
        if self.dx > 0: 
            self.rect.centerx += self.dx
            if self.rect.right - self.margin_right > tile_map.player_bounds_rect.right:
                self.rect.right = tile_map.player_bounds_rect.right + self.margin_right
                self.dx = 0.0

        if self.dx < 0:
            self.rect.centerx += self.dx
            if self.rect.left + self.margin_left < tile_map.player_bounds_rect.left:
                self.rect.left = tile_map.player_bounds_rect.left - self.margin_left
                self.dx = 0.0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号