blob_enemy.py 文件源码

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

项目:pyclimber 作者: manixaist 项目源码 文件源码
def update(self, tile_map):
        """Updates the blob sprite's position"""

        if not self.dying:
            last_dx = self.dx
            super().update(tile_map, tile_map.block_group)
            # Blobs only stop when they hit a wall so reverse course
            if last_dx != 0 and self.dx == 0:
                self.facing_left = not self.facing_left
                if self.facing_left:
                    self.dx = 1.0
                else:
                    self.dx = -1.0

            # Check if the blob is over the "exit" for the enemies, and if so, drop it down
            if tile_map.drainrect.colliderect(self.rect):
                self.dying = True
                self.falling = True
                self.falling_frames = 1
        else:
            if self.dy < self.settings.terminal_velocity:
                self.dy += self.settings.gravity

            self.rect.centery += self.dy
            self.falling_frames += 1

            if self.rect.top > self.screen_rect.bottom:
                self.kill()

        self.finish_update()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号