コード例 #1
0
 def paste(self, other, offset=(0,0)):
     """Insert content of another map."""
     vlen = len(self.vertexes)
     ilen = len(self.sidedefs)
     slen = len(self.sectors)
     for vx in other.vertexes:
         x, y = vx.x, vx.y
         self.vertexes.append(Vertex(x+offset[0], y+offset[1]))
     for line in other.linedefs:
         z = util.copy(line)
         z.vx_a += vlen
         z.vx_b += vlen
         if z.front != -1: z.front += ilen
         if z.back != -1: z.back += ilen
         self.linedefs.append(z)
     for side in other.sidedefs:
         z = util.copy(side)
         z.sector += slen
         self.sidedefs.append(z)
     for sector in other.sectors:
         z = util.copy(sector)
         self.sectors.append(z)
     for thing in other.things:
         z = util.copy(thing)
         z.x += offset[0]
         z.y += offset[1]
         self.things.append(z)
コード例 #2
0
 def draw_sector(self, vertexes, sector=None, sidedef=None):
     """Draw a polygon from a list of vertexes. The vertexes may be
     either Vertex objects or simple (x, y) tuples. A sector object
     and prototype sidedef may be provided."""
     assert len(vertexes) > 2
     firstv = len(self.vertexes)
     firsts = len(self.sidedefs)
     if sector  is None: sector  = Sector()
     if sidedef is None: sidedef = Sidedef()
     self.sectors.append(util.copy(sector))
     for i, v in enumerate(vertexes):
         if isinstance(v, tuple):
             x, y = v
         else:
             x, y = v.x, v.y
         self.vertexes.append(Vertex(x, y))
     for i in range(len(vertexes)):
         side = util.copy(sidedef)
         side.sector = len(self.sectors)-1
         self.sidedefs.append(side)
         self.linedefs.append(
           Linedef(vx_a=firstv+((i+1)%len(vertexes)),
           vx_b=firstv+i, front=firsts+i, flags=1))