How to use the 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 / tests / demo-2x.py View on Github external
def __init__(self, filename):
        self.init_buffer([screen.get_width() / 2, screen.get_height() / 2])

        tmx_data = pytmx.load_pygame("desert.tmx")
        map_data = pyscroll.TiledMapData(tmx_data)
        self.map_layer = pyscroll.BufferedRenderer(map_data, self.buffer_size)

        f = pygame.font.Font(pygame.font.get_default_font(), 20)
        t = ["scroll demo. press escape to quit",
             "arrow keys move"]

        self.text_overlay = [f.render(i, 1, (180, 180, 0)) for i in t]
        self.center = [self.map_layer.width/2,self.map_layer.height/2]
        self.camera_vector = [0, 0, 0]
        self.running = False
github Tuxemon / Tuxemon / tuxemon / core / components / map.py View on Github external
def initialize_renderer(self):
        """ Initialize the renderer for the map and sprites

        :rtype: pyscroll.BufferedRenderer
        """
        # TODO: Use self.edges == "stitched" here when implementing seamless maps
        visual_data = pyscroll.data.TiledMapData(self.data)
        clamp = (self.edges == "clamped")
        return pyscroll.BufferedRenderer(visual_data, prepare.SCREEN_SIZE, clamp_camera = clamp, tall_sprites = 2)
github WinterLicht / Chaos-Projectile / src / rendersystem.py View on Github external
def __init__(self, event_manager, world):
        """
        :param event_manager: event Manager
        :type event_manager: events.EventManager
        :param world: game world
        :type world: gameWorld.GameWorld
        """
        self.world = world
        self.event_manager = event_manager
        self.event_manager.register_listener(self)
        self.screen = world.screen
        w, h = world.screen.get_size()
        #Create new renderer/camera
        self.map_layer = pyscroll.BufferedRenderer(self.world.level.map_data,
                                                   (w, h),
                                                   clamp_camera=False,
                                                   colorkey=None,
                                                   alpha=True)
        #The player, enemies, items etc. should to be on top of
        #layer named in TMX "decoration behind"
        #Find layer number of the layer named "decoration behind"
        self.render_layer = 0
        for layer_index in range(len(self.world.level.tmx_data.layers)):
            if self.world.level.tmx_data.layers[layer_index].name == "walls":
                self.render_layer = layer_index #content will be drawn on top of walls layer
        self.group = pyscroll.PyscrollGroup(map_layer=self.map_layer,
                                            default_layer=self.render_layer)
        #Players image position is actually camera position
        player_image_position = self.world.appearance[self.world.player].rect
        #Parallax background
github bitcraft / pyscroll / apps / tutorial / quest.py View on Github external
# load data from pytmx
        tmx_data = load_pygame(self.filename)

        # setup level geometry with simple pygame rects, loaded from pytmx
        self.walls = list()
        for object in tmx_data.objects:
            self.walls.append(pygame.Rect(
                object.x, object.y,
                object.width, object.height))

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

        # create new renderer (camera)
        self.map_layer = pyscroll.BufferedRenderer(map_data, screen.get_size(), clamp_camera=False, tall_sprites=1)
        self.map_layer.zoom = 2

        # pyscroll supports layered rendering.  our map has 3 'under' layers
        # layers begin with 0, so the layers are 0, 1, and 2.
        # since we want the sprite to be on top of layer 1, we set the default
        # layer for sprites as 2
        self.group = PyscrollGroup(map_layer=self.map_layer, default_layer=2)

        self.hero = Hero()

        # put the hero in the center of the map
        self.hero.position = self.map_layer.map_rect.center
        self.hero._position[0] += 200
        self.hero._position[1] += 400

        # add our hero to the group
github bitcraft / pyscroll / tutorial / code / quest.py View on Github external
# load data from pytmx
        tmx_data = load_pygame(self.filename)

        # setup level geometry with simple pygame rects, loaded from pytmx
        self.walls = list()
        for object in tmx_data.objects:
            self.walls.append(pygame.Rect(
                object.x, object.y,
                object.width, object.height))

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

        # create new renderer (camera)
        self.map_layer = pyscroll.BufferedRenderer(map_data, screen.get_size())
        self.map_layer.zoom = 2

        # pyscroll supports layered rendering.  our map has 3 'under' layers
        # layers begin with 0, so the layers are 0, 1, and 2.
        # since we want the sprite to be on top of layer 1, we set the default
        # layer for sprites as 2
        self.group = PyscrollGroup(map_layer=self.map_layer, default_layer=2)

        self.hero = Hero()

        # put the hero in the center of the map
        self.hero.position = self.map_layer.map_rect.center

        # add our hero to the group
        self.group.add(self.hero)
github ShadowApex / DungeonTableMap / dungeon-table / dungeon-table.py View on Github external
self.walls.append(pygame.Rect(
                object.x, object.y,
                object.width, object.height))

        # create fog layer
        if self.fog_enabled:
            fog_width = tmx_data.tilewidth * tmx_data.width
            fog_height = tmx_data.tileheight * tmx_data.height
            self.fog_of_war = fog.FogOfWar((fog_width, fog_height), self.walls)

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

        # create new renderer (camera)
        # clamp_camera is used to prevent the map from scrolling past the edge
        self.map_layer = pyscroll.BufferedRenderer(map_data,
                                                   screen.get_size(),
                                                   clamp_camera=True)
        self.map_layer.zoom = 2


        # pyscroll supports layered rendering.  our map has 3 'under' layers
        # layers begin with 0, so the layers are 0, 1, and 2.
        # since we want the sprite to be on top of layer 1, we set the default
        # layer for sprites as 2
        self.group = pyscroll.PyscrollGroup(map_layer=self.map_layer)
        self.hero = Hero()

        # put the hero in the starting position of the map
        self.hero.position = get_starting_position(tmx_data.tilewidth,
                                                   starting_position)