本文整理汇总了Python中Level.Level.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Level.connect方法的具体用法?Python Level.connect怎么用?Python Level.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level.Level
的用法示例。
在下文中一共展示了Level.connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import connect [as 别名]
def load(self):
# get list of segment files
seg_file_pattern = os.path.join('assets','data','segdata','*[0-9].gif')
seg_files = glob.glob(seg_file_pattern)
# load segments into pygame surfaces
# creates Segments
# groups segments into levels
lvl_groups = {}
for seg_file in seg_files:
seg_id = string.split(os.path.basename(seg_file),'.')[1]
filename = os.path.basename(seg_file)
lvl_id = filename[:string.find(filename,'.')]
segment = Segment(lvl_id + '.' + seg_id)
if (lvl_id not in lvl_groups):
lvl_groups[lvl_id] = [segment]
else:
lvl_groups[lvl_id].append(segment)
# create Levels
for lvl_id in lvl_groups.keys():
segments = lvl_groups[lvl_id]
level = Level(lvl_id)
for segment in segments:
level.add_segment(segment)
level.connect()
self.levels[lvl_id] = level