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


Python Object.colour方法代码示例

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


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

示例1: load_level

# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import colour [as 别名]
def load_level(level_n):
    """(str) -> NoneType
    Loads level information from level_n into variables declared in __main__."""
    with open(get_level(level_n)) as file:
        line = file.readline()
        while line:
            if line[0] == "#":
                # a comment, ignore
                line = file.readline()
                continue

            # store objects created to be dealt with when resolving additional parameters later
            obj_col = []

            data = _get_level_dict()
            # parse data into raw pieces based on type parameter
            for raw_data in line.split():
                id, val = raw_data.split("=")
                data.update({id: val})

            # parse raw pieces corresponding to type parameter
            if data["type"] == "object":
                # how many times and in what direction do we repeat this object
                if data["repeat"]:
                    direction, num = data["repeat"].strip("()").split(",")
                    num = int(num)
                else:
                    # dummy direction
                    direction = "right"
                    num = 1

                rect = _parse_rect(data)
                w, h = rect.w, rect.h
                for i in range(num):
                    rect_c = rect.copy()
                    if direction == "right":
                        rect_c.x += i * w
                    elif direction == "left":
                        rect_c.x -= i * w
                    elif direction == "up":
                        rect_c.y -= i * h
                    elif direction == "down":
                        rect_c.y += i * h

                    obj = Object(rect_c)

                    obj_col.append(obj)
                    env_obj_col.append(obj)
            elif data["type"] == "bkgrd":
                obj = Object(_parse_rect(data))
                if data["colour"]:
                    obj.colour = _parse_colour(data["colour"])

                obj_col.append(obj)
                background.obj_col.append(obj)
            elif data["type"] == "kobold":
                obj = Kobold(_parse_rect(data))
                obj_col.append(obj)
                ai_col.append(obj)
            elif data["type"] == "navmesh":
                navmesh_col.extend(_parse_rects(data))

            _resolve_params(data, obj_col)

            line = file.readline()
开发者ID:Roolymoo,项目名称:fantasygame,代码行数:67,代码来源:main.py


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