本文整理汇总了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()