当前位置: 首页>>代码示例>>Python>>正文


Python Level.coinPaint方法代码示例

本文整理汇总了Python中Level.Level.coinPaint方法的典型用法代码示例。如果您正苦于以下问题:Python Level.coinPaint方法的具体用法?Python Level.coinPaint怎么用?Python Level.coinPaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Level.Level的用法示例。


在下文中一共展示了Level.coinPaint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import coinPaint [as 别名]

#.........这里部分代码省略.........

        self.__Kong.getLevelProperties()
        self.__play.getLevelProperties()
        self.__Kong.getDonkeyPosition()
        self.__play.getPlayerPosition()


    def gameLoop(self):
        """This is  the main game loop."""
        self.reload()
        self.steps = 0
        self.firaNo = 0
        pygame.mixer.init()
        pygame.mixer.music.load("music/route2.mp3")
        pygame.mixer.music.play()
        while True:
            self.__play.getLevelProperties()
            if self.__play.retLives() <= 0:
                break
            tty.setcbreak(sys.stdin)
            key = ord(sys.stdin.read(1))
            if key == 113 or key == 81:
                break
            if key == 32 and not self.__play.inAir():
                self.gameJumpLoop()
            else:
                self.updateEverything(key)
            self.__win = self.__play.victory()
            if self.__win:
                os.system("clear")
                self.reload(self.__play.retScore(), 2)
            if pygame.mixer.music.get_busy() != True:
                pygame.mixer.music.play()
        print "GAME OVER"

    def updateEverything(self, key):
        """Responsible for updating all instance variables.

        This includes things like positions of the Player,
        Donkey, fireballs etc. Also, responsible for information
        transfer between class objects."""

        if self.steps % 30 == 0 and self.firaNo < 1000:
            l, m = self.__firas[self.firaNo].spawn()
            self.__Lev.updateFBall(l, m)
            self.firaNo += 1
        self.__Kong.getLevelProperties()
        self.__play.getLevelProperties()
        for fira in self.__firas:
            fira.getLevelProperties()

        move = self.__play.motionController(key)
        self.__Lev.updatePlayer(move)
        self.firaList = []
        for i in range(self.firaNo):
            self.__firas[i].destroy()
            self.k, self.j = self.__firas[i].motionFire()
            self.__Lev.updateFBall(self.k, self.j)
            self.firaList.append(self.__firas[i].retFPos())
        self.__Lev.getFireCoordinates(self.firaList)
        if self.__play.fireDeath():
            self.__Lev.updatePlayer()
        pos = self.__Kong.randMove()
        # print move
        os.system('clear')
        #print self.__firas[0].pSpawnPoint, self.__firas[0].retFPos()
        # print self.__play.playerPs, self.__play.fireCoordinates
        self.firaList = []
        for i in range(self.firaNo):
            self.firaList.append(self.__firas[i].retFPos())
        self.__play.fireCoordinatesUpdate(self.firaList)
        # print self.__play.playerPos, self.__play.fireCoordinates
        if self.__play.fireDeath():
            self.__Lev.updatePlayer()
        self.firaList = []
        for i in range(self.firaNo):
            self.firaList.append(self.__firas[i].retFPos())
        self.__play.fireCoordinatesUpdate(self.firaList)
        if pos[1] != -1:
            self.__Lev.updateDonkey(pos[0], pos[1])
        self.__Lev.paintLadder()
        self.__Lev.coinPaint(self.__play.collectCoin())
        self.__Lev.levelLoad(self.__play.retScore(), self.__play.retLives(), self.__level)
        self.steps += 1

    def gameJumpLoop(self):
        """Handles the jump.

        Basically, one step is moved up and gravity is disabled
        for 3 more keypresses."""

        self.__play.setjFlag()
        self.updateEverything(87)
        for i in range(3):
            tty.setcbreak(sys.stdin)
            key = ord(sys.stdin.read(1))
            if key == 32:
                key = 87
            self.updateEverything(key)
        self.__play.unsetjFlag()
开发者ID:anirudhdahiya9,项目名称:Open-data-projecy,代码行数:104,代码来源:DKMain.py


注:本文中的Level.Level.coinPaint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。