本文整理汇总了Python中rectangle.Rectangle.updatepos方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.updatepos方法的具体用法?Python Rectangle.updatepos怎么用?Python Rectangle.updatepos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rectangle.Rectangle
的用法示例。
在下文中一共展示了Rectangle.updatepos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BoundedActor
# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import updatepos [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)