Example #1
0
 def __init__(self, area):
     path = 'F:/Practice/PyCharm/PygameTest/resource/Test/robot.png'
     super(RobotActor, self).__init__(pygame.image.load(path), area)
     self.__linePoints = [point2(), point2()]
     self.__startCord = self.area.barycenter()
     self.max_speed = 10
     self.__pathList = []
     self.__interPath = []
Example #2
0
    def __randomChord(self):
        angle1 = random.uniform(0, PI_DOUBLE)
        x_pos1, y_pos1 = self.width / 2 + 200 * cos(angle1), self.height / 2 + 200 * sin(angle1)
        angle2 = random.uniform(0, PI_DOUBLE)
        x_pos2, y_pos2 = self.width / 2 + 200 * cos(angle2), self.height / 2 + 200 * sin(angle2)

        Painter(self.sceneCanvas).Lines([point2(x_pos1, y_pos1), point2(x_pos2, y_pos2)], (0, 0, 0), 1, 0, 1)
        self.screen.blit(self.sceneCanvas, (0, 0))
Example #3
0
 def draw(self):
     for x in range(0, 800):
         noiseVal = noise((self.mouseX + x) * self.noiseScale,
                          self.mouseY * self.noiseScale)
         Painter(self.screen).Lines(
             [point2(x, self.mouseY + noiseVal * 80),
              point2(x, 600)],
             (noiseVal * 255, noiseVal * 255, noiseVal * 255), 1, 0)
Example #4
0
 def __init__(self, screen, config, startClock):
     super(TestPainterScene, self).__init__(screen, config, startClock)
     self.painter = Painter(self.screen)
     self.points = []
     for i in range(0, 6):
         x = random.randint(0, 800)
         y = random.randint(0, 400)
         self.points.append(vec2(x, y))
     self.rect = Rectangle(400, 100, 200, 100)
     self.line = Ray(vec2(200, 200), math.radians(30), 400)
     self.white = (255, 255, 255)
     self.tra = Triangle(point2(100, 100), point2(60, 180),
                         point2(140, 180))
     self.circle = Circle(400, 300, 100)
     self.ellipse = Ellipse(400, 300, 160, 70)
Example #5
0
 def __show(self, x=0, y=0):
     self.painter.resetCurrentMat()
     self.painter.translate(x, y)
     for i in range(len(self.__sentence)):
         current = self.__sentence[i]
         if current == 'F':
             self.painter.Lines([point2(0, 0), point2(0, -self.len)], (255, 255, 255), 1, 0)
             self.painter.translate(0, -self.len)
         elif current == '+':
             self.painter.rotate(self.__angle)
         elif current == '-':
             self.painter.rotate(-self.__angle)
         elif current == '[':
             self.painter.push()
         elif current == ']':
             self.painter.pop()
Example #6
0
 def __init__(self, x, y, angle=0, length=0):
     if isinstance(x, vec2):
         self.__init__(x.x, x.y, y, angle)
     else:
         self.pos = point2(x, y)
         self.dir = vec2.fromAngle(angle)
         self.length = length
Example #7
0
 def __normalList(self):
     self.__normalLis.clear()
     h, w = self.__As_MAP.unit_h, self.__As_MAP.unit_w
     for p in self.__pathList:
         self.__normalLis.append(point2(p[0] * w, p[1] * h))
     if len(self.__normalLis) > 1:
         self.__normalLis.pop(0)
     self.__A_Robot.setPathList(self.__normalLis)
Example #8
0
 def __init__(self, *args):
     super(drawingBoard, self).__init__(*args)
     self.color = (255, 255, 255)
     self.stork = 1
     self.isFill = False
     self.__start = point2()
     self.interval = 10
     self.caption = '测试场景:画板  按鼠标左键进行绘制,q键清屏'
Example #9
0
 def setup(self):
     for i in range(0, self.width, 20):
         y = mapping(noise(10), 0, 1, 0, 600)
         self.pixies.append(point2(i - 1, y))
         self.pixies.append(point2(i, 300))
Example #10
0
 def __segment(self, x, y, a):
     line = Line(point2(x, y), a, self.segLength)
     Painter(self.screen).Line(line, (255, 255, 255), 10, 1)
Example #11
0
 def __init__(self, x1, y1, x2, y2):
     if isinstance(x1, vec2):
         self.__init__(x1.x, x1.y, y1.x, y1.y)
     else:
         self.point1 = point2(x1, y2)
         self.point2 = point2(x2, y2)
Example #12
0
 def barycenter(self):
     return point2(self.x, self.y)
Example #13
0
 def barycenter(self):
     return point2(self.x + self.w / 2, self.y + self.h / 2)
Example #14
0
 def array(self):
     p1, p2 = point2(self.x, self.y), point2(self.x + self.w, self.y)
     p4, p3 = point2(self.x,
                     self.y + self.h), point2(self.x + self.w,
                                              self.y + self.h)
     return [p1, p2, p3, p4]
Example #15
0
 def barycenter(self):
     return point2((self.p1.x + self.p2.x + self.p3.x) / 3,
                   (self.p1.y + self.p2.y + self.p3.y) / 3)
Example #16
0
 def draw(self):
     for i in range(0, 100):
         s_point = point2(self.width / 2 + self.__x1(i), self.height / 2 + self.__y1(i))
         e_point = point2(self.width / 2 + self.__x2(i) + 20, self.height / 2 + self.__y2(i) + 20)
         Painter(self.screen).Lines([s_point, e_point], (255, 255, 255), 1, 0, 1)
     self.t += 0.15
Example #17
0
 def doMouseButtonUpEvent(self, Button):
     if Button == 1:
         self.__start = point2()
Example #18
0
 def doMouseButtonDownEvent(self, Button):
     if Button == 1:
         self.__start = point2(self.mousePos)
Example #19
0
 def draw(self):
     if not self.__start.isZero():
         Painter(self.screen).Lines([self.__start, point2(self.mousePos)], self.color, self.stork, 0, 1)
         self.__start = point2(self.mousePos)