How to use the pyscroll.quadtree.FastQuadTree function in pyscroll

To help you get started, we’ve selected a few pyscroll examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitcraft / pyscroll / pyscroll / quadtree.py View on Github external
in_se = item.right >= cx and item.bottom >= cy

            # If it overlaps all 4 quadrants then insert it at the current
            # depth, otherwise append it to a list to be inserted under every
            # quadrant that it overlaps.
            if in_nw and in_ne and in_se and in_sw:
                self.items.append(item)
            else:
                if in_nw: nw_items.append(item)
                if in_ne: ne_items.append(item)
                if in_se: se_items.append(item)
                if in_sw: sw_items.append(item)

        # Create the sub-quadrants, recursively.
        if nw_items:
            self.nw = FastQuadTree(nw_items, depth,
                                   (boundary.left, boundary.top, cx, cy))

        if ne_items:
            self.ne = FastQuadTree(ne_items, depth,
                                   (cx, boundary.top, boundary.right, cy))

        if se_items:
            self.se = FastQuadTree(se_items, depth,
                                   (cx, cy, boundary.right, boundary.bottom))

        if sw_items:
            self.sw = FastQuadTree(sw_items, depth,
                                   (boundary.left, cy, cx, boundary.bottom))
github bitcraft / pyscroll / pyscroll / quadtree.py View on Github external
if in_nw: nw_items.append(item)
                if in_ne: ne_items.append(item)
                if in_se: se_items.append(item)
                if in_sw: sw_items.append(item)

        # Create the sub-quadrants, recursively.
        if nw_items:
            self.nw = FastQuadTree(nw_items, depth,
                                   (boundary.left, boundary.top, cx, cy))

        if ne_items:
            self.ne = FastQuadTree(ne_items, depth,
                                   (cx, boundary.top, boundary.right, cy))

        if se_items:
            self.se = FastQuadTree(se_items, depth,
                                   (cx, cy, boundary.right, boundary.bottom))

        if sw_items:
            self.sw = FastQuadTree(sw_items, depth,
                                   (boundary.left, cy, cx, boundary.bottom))