How to use the pyscroll.TextureRenderer 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 / tests / demo_pysdl2.py View on Github external
def __init__(self, ctx, filename):
        self.ctx = ctx
        self.event = sdl.Event()
        self.running = False
        self.pressed = collections.defaultdict(bool)

        # load data from pytmx
        tmx_data = load_pysdl2_cffi(ctx, filename)

        # create new data source
        map_data = pyscroll.data.TiledMapData(tmx_data)

        # create new renderer
        screen_size = ctx.window.getWindowSize()
        self.map_layer = pyscroll.TextureRenderer(ctx, map_data, screen_size)
        self.center = [(i // self.map_layer.zoom) // 2 for i in map_data.pixel_size]

        # create a font and pre-render some text to be displayed over the map
        # f = pygame.font.Font(pygame.font.get_default_font(), 20)
        # t = ["scroll demo. press escape to quit",
        #      "arrow keys move"]

        # save the rendered text
        # self.text_overlay = [f.render(i, 1, (180, 180, 0)) for i in t]

        # set our initial viewpoint in the center of the map

        # the camera vector is used to handle camera movement
        self.camera_acc = [0, 0, 0]
        self.camera_vel = [0, 0, 0]
        self.last_update_time = 0