Beispiel #1
0
 def _update_length(self):
     while self.length > self._length:
         # keep popping tails until we have a delta to move by that isn't
         # larger than the tail length
         (x1, y1), (x2, y2) = self.points[0:2]
         dx = x1 - x2
         dy = y1 - y2
         # delta length
         dlen = self._length - self.length
         #
         if math.fabs(dlen) > (self.tail_len - self.width):
             # remove tail point
             self.points.pop(0)
             # angle of line just after (towards head) tail
             #(x1, y1), (x2, y2) = self.points[0:2]
             a = util.points_angle(*self.points[0:2])
             #a = math.atan2(x1 - x2, y1 - y2)
             # adjust new tail
             p = self.points[0]
             p.x += math.cos(a) * self.width
             p.y += math.sin(a) * self.width
         else:
             a = math.atan2(dy, dx)
             # new dx, dy
             # what to move x1, y1 by
             dx = math.cos(a) * dlen
             dy = math.sin(a) * dlen
             self.points[0] = Point(x1 + dx, y1 + dy)
             break
 def _update_length(self):
     while self.length > self._length:
         # keep popping tails until we have a delta to move by that isn't
         # larger than the tail length
         (x1, y1), (x2, y2) = self.points[0:2]
         dx = x1 - x2
         dy = y1 - y2
         # delta length
         dlen = self._length - self.length
         #
         if math.fabs(dlen) > (self.tail_len - self.width):
             # remove tail point
             self.points.pop(0)
             # angle of line just after (towards head) tail
             # (x1, y1), (x2, y2) = self.points[0:2]
             a = util.points_angle(*self.points[0:2])
             # a = math.atan2(x1 - x2, y1 - y2)
             # adjust new tail
             p = self.points[0]
             p.x += math.cos(a) * self.width
             p.y += math.sin(a) * self.width
         else:
             a = math.atan2(dy, dx)
             # new dx, dy
             # what to move x1, y1 by
             dx = math.cos(a) * dlen
             dy = math.sin(a) * dlen
             self.points[0] = Point(x1 + dx, y1 + dy)
             break
Beispiel #3
0
    def polygon_pointlist(self):
        points_l = []
        points_r = []
        distance = self.width / 2
        points = self.points

        def _rot_line((p1, p2), angle_delta, d):
            angle = util.points_angle(p1, p2) + angle_delta
            return (p1.move(angle, d), p2.move(angle, d))
Beispiel #4
0
    def polygon_pointlist(self):
        points_l = []
        points_r = []
        distance = self.width / 2
        points = self.points

        def _rot_line((p1, p2), angle_delta, d):
            angle = util.points_angle(p1, p2) + angle_delta
            return (p1.move(angle, d), p2.move(angle, d))
    def _update_length(self):
        if self.tail_length < self.min_tail_length:
            self._bodypoints.pop(0)

        while (self.segments_length_sum > self.length):
            # distance to adjust tail so that the worm is the correct length
            correction_length = self.length - self.segments_length_sum
            if math.fabs(correction_length) < 0.001:
                # get out of here with that, come back when you got some
                # correctin' to do!
                break
            # the direction to correct in
            correction_angle = util.points_angle(*self.tail_segment)
            # is there enough tail to make that correction?
            if math.fabs(correction_length) > self.tail_length:
                self._bodypoints.pop(0)
            else:
                self.tail_point = self.tail_point.move(correction_angle,
                                                       correction_length)
    def _update_length(self):
        if self.tail_length < self.min_tail_length:
            self._bodypoints.pop(0)

        while (self.segments_length_sum > self.length):
            # distance to adjust tail so that the worm is the correct length
            correction_length = self.length - self.segments_length_sum
            if math.fabs(correction_length) < 0.001:
                # get out of here with that, come back when you got some
                # correctin' to do!
                break
            # the direction to correct in
            correction_angle = util.points_angle(*self.tail_segment)
            # is there enough tail to make that correction?
            if math.fabs(correction_length) > self.tail_length:
                self._bodypoints.pop(0)
            else:
                self.tail_point = self.tail_point.move(correction_angle,
                                                       correction_length)