build-engine-randomizer icon indicating copy to clipboard operation
build-engine-randomizer copied to clipboard

mirroring maps

Open Die4Ever opened this issue 1 year ago • 0 comments

some WIP code from buildmapbase.py...

    def MirrorMap(self):
        # TODO, need to figure out re-ordering of walls, they need to be counterclockwise
        # probably need to compare coordinates and do some sorting
        # actually reversing the list might be good enough, maybe the issue is with all the pointer/index dependencies?
        self.full_rewrite = True
        x=1
        y=-1

        self.startPos[0] *= x
        self.startPos[1] *= y

        for w in self.walls:
            w.pos[0] *= x
            w.pos[1] *= y

        for sect in self.sectors:
            shapes = [[]]
            wallptr = sect.wallptr
            numwalls = sect.wallnum
            for i in range(wallptr, wallptr + numwalls):
                shapes[-1].append(i)
                if self.walls[i].next_wall != -1:
                    shapes.append([])

            for shape in shapes:
                rev = shape.copy()
                rev.reverse()
                for a, b in zip(shape, rev):
                    if a >= b:
                        break
                    walla:Wall = self.walls[a]
                    wallb:Wall = self.walls[b]

                    next_wall_a = walla.next_wall
                    next_sector_wall_a = walla.next_sector_wall
                    next_sector_a = walla.next_sector

                    next_wall_b = wallb.next_wall
                    next_sector_wall_b = wallb.next_sector_wall
                    next_sector_b = wallb.next_sector

                    walla.next_wall = next_wall_b
                    #walla.next_sector_wall = next_sector_wall_b
                    #walla.next_sector = next_sector_b

                    wallb.next_wall = next_wall_a
                    #wallb.next_sector_wall = next_sector_wall_a
                    #wallb.next_sector = next_sector_a

                    self.walls[a] = wallb
                    self.walls[b] = walla

        for s in self.sprites:
            s.pos[0] *= x
            s.pos[1] *= y

Die4Ever avatar Apr 07 '23 00:04 Die4Ever