本文整理汇总了Python中circle.Circle.move方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.move方法的具体用法?Python Circle.move怎么用?Python Circle.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.move方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import move [as 别名]
class Controller:
def __init__(self):
self.circle = Circle(width/2, height/2, 100)
def draw(self):
background(0, 0, 0)
stroke(50, 50, 200) # set stroke color bluish
self.circle.draw()
self.circle.move(0.25,0.25)
示例2: __init__
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import move [as 别名]
class Controller:
def __init__(self):
self.circlea = Circle(PVector(width/2, height/2), 100, PVector(1, 1))
self.circleb = Circle(PVector(width/2, height/2), 100, PVector(3, 3))
def draw(self):
background(0, 0, 0)
self.circlea.draw()
self.circleb.draw()
self.circlea.move()
self.circleb.move()
示例3: __init__
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import move [as 别名]
class Controller:
def __init__(self): # sx, sy
self.circlea = Circle(width/2, height/2, 100, 1, 1)
self.circleb = Circle(width/2, height/2, 100, 3, 3)
def draw(self):
background(0, 0, 0)
self.circlea.draw()
self.circleb.draw()
self.circlea.move()
self.circleb.move()
示例4: __init__
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import move [as 别名]
class CircularPlayer:
def __init__(self, initialPosition):
self.playerCircle = Circle(initialPosition, 13, RED)
self.speed = 5
self.perspective = Box(initialPosition, float(WINDOWHEIGHT), float(WINDOWWIDTH), 0.0, (0, 255, 0))
def updatePerspectiveByPosShift(self, xShift, yShift):
self.perspective.updateByPosShift(xShift, yShift)
def move(self, directionShift, listOfObjects):
direction = self.perspective.rotation + directionShift
centerBeforeMove = self.playerCircle.center
self.playerCircle.move(direction, self.speed, listOfObjects)
xShift = self.playerCircle.center[0] - centerBeforeMove[0]
yShift = self.playerCircle.center[1] - centerBeforeMove[1]
self.updatePerspectiveByPosShift(xShift, yShift)
def rotate(self, rotation, listOfObjects):
self.perspective.rotation = self.perspective.rotation + rotation
def draw(self, surface, color):
self.playerCircle.draw(surface, color)
def getWhatToDraw(self, listOfObjects):
circlesToDraw, boxesToDraw = [] , []
whatToDraw = [circlesToDraw, boxesToDraw]
for circle in listOfObjects[circles]:
if self.perspective.doesBoxContainCircle(circle) == True:
whatToDraw[circles].append(circle)
for box in listOfObjects[boxes]:
if self.perspective.doesBoxContainBox(box) == True:
whatToDraw[boxes].append(box)
whatToDraw[circles].append(self.playerCircle)
return whatToDraw
def drawMyView(self, surface, playingField, listOfObjects):
whatToDraw = self.getWhatToDraw(listOfObjects)
whatToDraw[boxes].insert(0, playingField)
visualBoxes = []
for i in range (0, len(whatToDraw[boxes])):
visualBoxes.append(Box(whatToDraw[boxes][i].center, whatToDraw[boxes][i].width, whatToDraw[boxes][i].height, whatToDraw[boxes][i].rotation, whatToDraw[boxes][i].color))
visualBoxes[i].center = (WINDOWWIDTH/2 + (visualBoxes[i].center[0] - self.perspective.center[0]), WINDOWHEIGHT/2 + (visualBoxes[i].center[1] - self.perspective.center[1]))
visualBoxes[i].rotateAroundPoint(CENTEROFWINDOW, -math.pi/2 - self.perspective.rotation)
visualBoxes[i].draw(surface)
visualCircles = []
for i in range (0, len(whatToDraw[circles])):
visualCircles.append(Circle(whatToDraw[circles][i].center, whatToDraw[circles][i].radius, whatToDraw[circles][i].color))
visualCircles[i].center = (WINDOWWIDTH/2 + (visualCircles[i].center[0] - self.perspective.center[0]), WINDOWHEIGHT/2 + (visualCircles[i].center[1] - self.perspective.center[1]))
visualCircles[i].center = function.rotateAroundPoint(visualCircles[i].center, CENTEROFWINDOW, -math.pi/2 - self.perspective.rotation)
visualCircles[i].draw(surface)
示例5: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import move [as 别名]
#!/usr/local/bin/python3
#FILE: lap4.1.py
#DATE: 07/20/14
#DESC: Exercise in modules
from shape import Shape
from circle import Circle
c1 = Circle(7, 10, 10)
c2 = Circle(25, 0, 0)
c1_xdelta = 2
c1_ydelta = 3
c2_xdelta = 1
c2_ydelta = -1
for i in range(1, 20):
if i%10 == 0:
c1.move(-10 + i, -10 - i )
else:
c1.move(c1_xdelta, c1_ydelta)
c2.move(c2_xdelta, c2_ydelta)
# Print c1.__str__()
print(c1)
#Print c2.__str__()
print(c2)
#Print collision True or None
print("Collision: {collision}".format(collision = Circle.is_collision(c1, c2)))
示例6: Circle
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import move [as 别名]
#!/usr/local/bin/python3
# NAME: Richard Tzeng
# FILE: lab4.1.py
# DATE: <21014-07-20 Mon>
# DESC: This script returns the size of the circle and whether the two circles
# collide.
from shape import Shape
from circle import Circle
c1 = Circle(0, 0, 20)
c2 = Circle(0, 0, 20)
c1_xdelta = 2
c1_ydelta = 3
c2_xdelta = 1
c2_ydelta = -1
for i in range (1, 20):
c1.move(c1_xdelta, c1_ydelta)
c2.move(c2_xdelta, c2_ydelta)
# Print c1.__str__()
print(c1)
# Print c2.__str__()
print(c2)
# Print collision True or None
print("Collision: {collision}".format(collision = Circle.is_collision(c1,c2)))