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


Python Shape.autonomous方法代码示例

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


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

示例1: addShapes

# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import autonomous [as 别名]
 def addShapes(self):
   """adds more shapes to the world"""
   # how many shapes to generate
   # we want roughly one piece per screen
   screenArea = self.displayGridSize[0] * self.displayGridSize[1]
   worldArea = self.world.cols * self.world.rows
   minTotalShapes = 1 + int(worldArea / screenArea)
   #logging.debug("generating {0} shape pieces...".format(minTotalShapes))
   curTotalShapes = 0
   shapes = []
   while curTotalShapes < minTotalShapes:
   # until enough shape generated
     # create new shape, placed randomly
     num_sides = random.randint(3,6)
     newShape = Shape(self.display, self, self.character_size, num_sides)
     newShape.autonomous = True  # all new shapes will be autonomous by default
     
     # add shape to the list of objects
     if(self.world.addObject(newShape)):
       curTotalShapes += 1
       shapes.append(newShape)
       logging.debug ("shape #{0} added to the map, id {1} with position {2} and rect={3}".format(curTotalShapes, newShape, newShape.getMapTopLeft(), newShape.rect))
   # now there's enough shape in the world
   self.shapes = shapes
   return shapes
开发者ID:benjaminbradley,项目名称:pacworld,代码行数:27,代码来源:map.py


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