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


Python Rectangle.collide方法代码示例

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


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

示例1: BoundedActor

# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import collide [as 别名]
class BoundedActor( Actor ):
  """
    Actor class with bounding rectangle
  """
  def __init__( self, **kwargs ):
    """

      Keyword Arguments: 
        - model: 
        - texture: 
        - drawmode: 
        - rectdim: 
        - boundoffset: (x,y) offset of bounding rectangle from (0,0) in model coordinates, used
                       to position the bounding rectangle within the actor model
      
      self, model, texture=None, drawmode='polygon'
    """
    try:
      texture  = kwargs.get( 'texture', None )
      drawmode = kwargs.get( 'drawmode', 'polygon' )
      self._boundoffset = kwargs.get( 'boundoffset', (0,0) )
      super(BoundedActor,self).__init__( kwargs['model'], texture, drawmode )

      self._bound = Rectangle( **kwargs )
    except KeyError:
      print "Bounded Actor requires a model"
#=================================================================================================
  def draw( self, pos, name,drawbound=False ):
    """
    """
    super(BoundedActor,self).draw(pos,name)
    if drawbound: self._bound.draw((pos[0]+self._boundoffset[0],pos[1]+self._boundoffset[1]),name)
    else: self._bound.updatepos( (pos[0]+self._boundoffset[0],pos[1]+self._boundoffset[1]) )
#=================================================================================================
  def collide(self,point):
    """
    """
    return self._bound.collide(point)
开发者ID:doggerelverse,项目名称:gelly,代码行数:40,代码来源:boundedactor.py


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