pyscroll package

Submodules

pyscroll.pyscroll

class pyscroll.pyscroll.BufferedRenderer(data, size, colorkey=None, padding=4, clamp_camera=False)

Bases: object

Renderer that can be updated incrementally

Base class to render a map onto a buffer that is suitable for blitting onto the screen as one surface, rather than a collection of tiles.

The class supports differed rendering, multiple layers, shapes and layering surfaces (usually from sprites) in the map, creating an illusion of depth.

This class works well for maps that operate on a small display and where the map is much larger than the display, but you will get poor performance if the map is smaller than the display.

The buffered renderer must be used with a data class to get tile and shape information. See the data class api in pyscroll.data, or use the built in pytmx support.

blit_tiles(iterator)

Bilts (x, y, layer) tuples to buffer from iterator

center(coords)

center the map on a pixel

draw(surface, rect, surfaces=None)

Draw the map onto a surface

pass a rect that defines the draw area for:
dirty screen update support drawing to an area smaller that the whole window/screen

surfaces may optionally be passed that will be blited onto the surface. this must be a list of tuples containing a layer number, image, and rect in screen coordinates. surfaces will be drawn in order passed, and will be correctly drawn with tiles from a higher layer overlapping the surface.

draw_objects()

Totally unoptimized drawing of objects to the map

flush()

Blit the tiles and block until the tile queue is empty

generate_default_image()
get_edge_tiles(offset)

Get the tile coordinates that need to be redrawn

get_tile_image(position)
redraw()

redraw the visible portion of the buffer – it is slow.

scroll(vector)

scroll the background in pixels

set_data(data)
set_size(size)

Set the size of the map in pixels

update(dt=None)

Draw tiles in the background

the drawing operations and management of the buffer is handled here. if you are updating more than drawing, then updating here will draw off screen tiles. this will limit expensive tile blits during screen draws. if your draw and update happens every game loop, then you will not benefit from updates, but it won’t hurt either.

update_queue(iterator)

Add some tiles to the queue

class pyscroll.pyscroll.ThreadedRenderer(*args, **kwargs)

Bases: pyscroll.pyscroll.BufferedRenderer

Off-screen tiling is handled in a thread

flush()
update(dt=None)
update_queue(iterator)
class pyscroll.pyscroll.TileThread(*args, **kwargs)

Bases: threading.Thread

poll the tile queue for new tiles and draw them to the buffer

run()

pyscroll.data

This file contains two data classes for use with pytmx.

pyscroll.data.TiledMapData

alias of LegacyTiledMapData

pyscroll.util

class pyscroll.util.PyscrollGroup(*args, **kwargs)

Bases: pygame.sprite.LayeredUpdates

Layered Group with ability to center sprites and scrolling map

center(value)

Center the group/map on a pixel

The basemap and all sprites will be realigned to draw correctly. Centering the map will not change the rect of the sprites.

draw(surface)

Draw all sprites and map onto the surface

Group.draw(surface): return None Draws all of the member sprites onto the given surface.

update(dt)
pyscroll.util.draw_shapes(tmx_data)

create a new tile layer from a shape layer totally not working

Module contents

Table Of Contents

This Page