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


Python Circle.move方法代码示例

本文整理汇总了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)
开发者ID:charlesxian,项目名称:simulation_spring_2016_repo,代码行数:10,代码来源:example2-controller.py

示例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()
开发者ID:charlesxian,项目名称:simulation_spring_2016_repo,代码行数:13,代码来源:controller.py

示例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()
开发者ID:charlesxian,项目名称:simulation_spring_2016_repo,代码行数:13,代码来源:example3-controller.py

示例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)
开发者ID:KoenP,项目名称:topdown,代码行数:65,代码来源:circularplayer.py

示例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)))
开发者ID:addisonu,项目名称:Other_Primer,代码行数:30,代码来源:lab4.1.py

示例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)))
开发者ID:thefront,项目名称:coding-practice,代码行数:29,代码来源:lab4.1.py


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