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


Python Timeline.progress方法代码示例

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


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

示例1: levelManager

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import progress [as 别名]

#.........这里部分代码省略.........
            #for argument in argRight:
            #    if "[" in argument:
            #        argument = eval(argument)
            try:
                class_dict[glyph] = classes[name]
            except KeyError:
                raise KeyError("Error parsing glyph {!r}: no class named {}"
                               "".format(glyph, name))
            arg_dict[glyph] = args
        # Parse the map
        map_ = [line.rstrip() for line in map_data.rstrip().split('\n')]
        width = max(len(line) for line in map_)
        height = len(map_)
        # Create the level instance

        level = levelManager(width, height)
        #print("level width={} height={}".format(width, height), file=sys.stderr)
        for y, line in enumerate(map_[::-1], 1):
            for x, char in enumerate(line, 1):
                if char != ' ':
                    #try: #this almost works, but I don't have a python resource at hand
                        if class_dict[char] is Player:
                            level.setPlayer(Player(x, y, level))
                            level.camera.player = level.player
                            class_dict["."](x, y, level, **arg_dict["."])
                        else:
                            # automatically places floors under all non-floor, non-wall, non-triggertile tiles!
                            if class_dict[char] in (Wall, Floor, TriggerTile, Door):
                                #print("adding {} at x={} y={}".format(class_dict[char], x, y), file=sys.stderr)
                                try:
                                    class_dict[char](x, y, level, **arg_dict[char])
                                except TypeError:
                                    raise TypeError("Error parsing glyph {!r}: no class named {}"
                                                    "".format(char, arg_dict[char]))
                                except ValueError:
                                    config.error_out = (class_dict, arg_dict)
                                    raise ValueError("Error parsing glyph {!r}: illegal value: \n{!s}"
                                                    "".format(char, arg_dict[char]))
                            else:
                                class_dict[char](x, y, level, **arg_dict[char])
                                class_dict["."](x, y, level, **arg_dict["."])
                    #except:
                        #raise(KeyError ("There isn't a matching line for glyph: ", char))
        # Triggers ...?
        level.name = name
        return level

    def setPlayer(self, player):
        self.player = player

    def update(self):
        if(config.world.currentLevel == self):
            for actor in self.timeline:
                actor.act()
            self.timeline.progress()
        else:
            config.world.currentLevel.timeline.addToTop(config.player)
            config.world.update()

    def draw(self):
        if self.player is None:
            raise RuntimeError("You didn't call levelManager.setPlayer()!!!!")
        if(config.world.currentLevel == self):
            unicurses.erase()
            self.camera.draw(self.player.xpos, self.player.ypos)
            self.output_buffer.output()

    def drawDropInputParser(self):
        self.drawInventoryInputParser()

    def drawInventoryInputParser(self):
        unicurses.erase()
        self.camera.drawHUDBoundaries()
        for index, item in enumerate(self.player.inventory.inventoryList):
            unicurses.attron(unicurses.COLOR_PAIR(config.colorDict["white"]))
            unicurses.mvaddstr(index+1, 1, self.player.inventory.letterList[index+1]+") "+self.player.inventory.inventoryList[index].description)
            unicurses.attroff(unicurses.COLOR_PAIR(config.colorDict["white"]))

    def drawLookInputParser(self, xLook, yLook):
        if(self.grid.getCell(xLook, yLook).hasBeenSeen):
            self.grid.drawCellBold(xLook, yLook, self.player.xpos, self.player.ypos, int(self.camera.lensWidth/2), int(self.camera.lensHeight/2))
        elif (abs(xLook - self.player.xpos) < self.camera.adjLensWidth) and abs(self.player.ypos-yLook) < self.camera.adjLensHeight:
            self.camera.drawArbitrary(xLook, yLook, '*', 'blue')

    def populateFloor(self):
        for y in range(1, self.height+1):
            for x in range(1, self.width+1):
                if all((not isinstance(i, Wall) and (not isinstance(i, TriggerTile))) for i in self.grid.get(x, y)):
                    #for debugging, use below to print column/row indices
                    #entity(x, y, self, str(y))
                    #if(not isinstance(i, TriggerTile)):
                    Floor(x, y, self, display='.')

    def populateWalls(self):
        for x in range(1, self.width+1):
            Wall(x, 1, self)
            Wall(x, self.height, self)
        for y in range(2, self.height):
            Wall(1, y, self)
            Wall(self.width, y, self)
开发者ID:Trial-In-Error,项目名称:raidlike,代码行数:104,代码来源:levelManager.py


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