How to use the pyscroll.pyscroll.BufferedRenderer 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 / pyscroll.py View on Github external
tile = get_tile((x, y, l))
                if tile:
                    blit(tile, (x * tw - ltw, y * th - tth))

    def redraw(self):
        """ redraw the visible portion of the buffer -- it is slow.
        """
        queue = product(range(self.view.left, self.view.right),
                        range(self.view.top, self.view.bottom),
                        self.data.visible_tile_layers)

        self.update_queue(queue)
        self.flush()


class ThreadedRenderer(BufferedRenderer):
    """ Off-screen tiling is handled in a thread
    """

    def __init__(self, *args, **kwargs):
        BufferedRenderer.__init__(self, *args, **kwargs)
        self.flush_on_draw = False
        self.queue = queue.Queue()

        self.thread = TileThread(renderer=self)
        self.thread.start()

    def update(self, dt=None):
        pass

    def flush(self):
        self.queue.join()