blob_enemy.py 文件源码

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

项目:pyclimber 作者: manixaist 项目源码 文件源码
def handle_collision(self, collision_list, group):
        """Given a list of sprites that collide with the sprite, alter state such as position, velocity, etc"""
        # If there's only 1 block, then we're over an edge, so do nothing in that case
        # and just let the sprite fall, otherwise, clamp to the top of the block
        if collision_list:
            if len(collision_list) > 1:
                self.falling = False
                self.falling_frames = 1
                self.dy = 0
                self.rect.bottom = collision_list[0].rect.top
            elif len(collision_list) == 1:
                if self.facing_left and self.rect.right > collision_list[0].rect.left:
                    self.falling = False
                    self.falling_frames = 1
                    self.dy = 0
                    self.rect.bottom = collision_list[0].rect.top
                elif not self.facing_left and self.rect.left < collision_list[0].rect.right:
                    self.falling = False
                    self.falling_frames = 1
                    self.dy = 0
                    self.rect.bottom = collision_list[0].rect.top
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号