예제 #1
0
 def draw_outbound(self, ctx):
     # Draw outbound segments
     for platform, destination, line, subtrack, leaves_start, finishes_end in self.outbounds:
         # Draw the ends if they've not been done yet.
         if not platform.drawn:
             platform.draw(ctx)
         if not destination.drawn:
             destination.draw(ctx)
         # Make sure which ends we're using
         if leaves_start:
             start_point = platform.start_point
             start_dir = platform.direction.left.left.left.left
         else:
             start_point = platform.end_point
             start_dir = platform.direction
         if finishes_end:
             end_point = destination.end_point
             end_dir = destination.direction.left.left.left.left
         else:
             end_point = destination.start_point
             end_dir = destination.direction
         # Draw!
         Segment(
             start_point,
             start_dir,
             end_point,
             end_dir,
             line.colors,
             subtrack=subtrack,
         ).draw(ctx)
예제 #2
0
    def __init__(self, n):
        """
        Constructor
        :param n: Length of pipe
        :type n: int
        """
        self.length = n  # get a length of pipe
        self.segments = [Segment()
                         for i in range(n)]  # store all segments in one pipe

        # check if segments in pipe can have neighbours
        if len(self.segments) > 1:
            # for each segments set its neighbours
            for i in range(len(self.segments)):
                # set neighbour for the first segment
                if i == 0:
                    self.segments[0].add_neighbour(self.segments[1])
                    self.segments[0].next = self.segments[1]
                # set neighbour for the last segment
                elif i == len(self.segments) - 1:
                    self.segments[-1].add_neighbour(self.segments[-2])
                    self.segments[-1].next = None
                else:
                    self.segments[i].add_neighbour(self.segments[i - 1])
                    self.segments[i].add_neighbour(self.segments[i + 1])
                    self.segments[i].next = self.segments[i + 1]
        else:
            self.segments[0].next = None
예제 #3
0
 def draw(self, ctx):
     "Draws this platform on the map"
     if self.line.code != "none":
         Segment(
             self.start_point,
             self.direction,
             self.end_point,
             self.direction,
             self.line.colors,
             platform = 0,
             dashed = True,
         ).draw(ctx)
     self.drawn = True
예제 #4
0
 def draw(self, ctx):
     "Draws this platform on the map"
     # Draw the main platform segment
     if self.line.code != "none":
         Segment(
             self.start_point,
             self.direction,
             self.end_point,
             self.direction,
             self.line.colors,
             platform = self.platform_side,
             platform_color = self.color,
         ).draw(ctx)
     self.drawn = True
예제 #5
0
 def __init__(self, n):
     """
     Constructor
     :param n: Length of pipe
     :type n: int
     """
     self.length = n
     self.boxes = [Segment() for i in range(self.length)]
     if len(self.boxes) > 1:
         for i in range(self.length):
             if i == 0:
                 # self.boxes[0].next = self.boxes[1]
                 self.boxes[0].add_neighbour(self.boxes[1])
             elif i == self.length - 1:
                 # self.boxes[-1].next = None
                 pass
             else:
                 # self.boxes[i].next = self.boxes[i + 1]
                 self.boxes[i].add_neighbour(self.boxes[i + 1])
     else:
         # self.boxes[0].next = None
         pass