如何从pygame中的起始位置进行背景加载

时间:2019-07-05 15:52:14

标签: python pygame

我正在创建3个级别的游戏。玩家可以正确地从地图的起点移动到1和2级的终点,但是当到达3级时,它将从最后一点加载地图。请查看我已上传的视频-https://www.youtube.com/watch?v=KtEW4cbpT5A&feature=youtu.be-在这里,您可以看到玩家进入第三级时地图不会从开始加载,而是从某个中间点加载,并且玩家也一样(它在地图中间生成)不是起点)

到目前为止我尝试过的,

                   if self.level == 3:
                # Moving Coins
                self.updateCoinPos(self.coin_forest)

                # Moving Platform_sky
                self.updatePlatformPos(self.platform_forest)

                self.updateEnemyPos(self.enemy_forest)

                # For moving enemies dead bodies in lvl 2
                for e in self.enemy_forest:
                    if e.enemyDead:
                        e.x += self.hero.velocity

                if self.hero.x >= startScrollingPos_forest:
                    self.noBorderCross = False

                self.coordinates = 3700

                # Updating rect of Platform_sky
                self.updatePlatformRect(self.platform_forest)

                self.updateCoinRect(self.coin_forest)

        self.CameraX += self.hero.velocity

    if self.CameraX >= self.coordinates:
        self.noCameraCross = False
        if self.hero.x < 890 - self.hero.velocity - self.hero.width:
            self.hero.x += self.hero.velocity
            #self.level = 2

在这个问题上,谁能帮助我-我想做的就是,当玩家移动时,相机也应该与玩家一起向前移动,这最终会加载游戏的其他部分-预先感谢

这是我的代码的链接以供参考-https://pastebin.com/Zv5cRLLN

0 个答案:

没有答案