skip to navigation
skip to content

pyscroll 2.06

Pygame Scrolling - Python 2.7

Latest Version: 2.15.1


for Python 2.7 and Pygame 1.9

A simple, fast module for adding scrolling maps to your new or existing game.

Compatible with pytmx (use the python2 branch):

What the heck is it?

pyscroll is a generic module for making a fast scrolling image with PyGame. It uses a lot of magic to get reasonable
framerates out of PyGame. It only exists to draw a map. It doesn't load images or data, so you can use your own custom
data structures, tile storage, ect.

The included class, BufferedRenderer, gives great framerates, supports layered rendering and can draw itself. It uses
more memory than a typical map would, but gives much better performance.


- Fast and small footprint
- Layered drawing
- Dirty screen updates


Basically, you need an object that conforms to a simple protocol defined in pyscroll.TiledMapData. And as luck would
have it, I've included an object that works with my Tiled TMX library.

# Using a pyscroll map layer

pyscroll isn't a replacement for any PyGame objects. You can it it along with your Sprites and SpriteGroups.

# Load TMX data (optional)
tmx_data = pytmx.load_pygame("desert.tmx")

# Make data source for the map
map_data = pyscroll.TiledMapData(tmx_data)

# Make the scrolling layer
size = (400, 400)
map_layer = pyscroll.BufferedRenderer(map_data, size)

# Center the layer on a pixel, 200))

# Draw the layer
rect = pygame.Rect(0,0,200,200)
map_layer.draw(screen, rect)

# Draw the layer in the background (optional)

See the demo in tests for code.

Adapting Existing Games / Map Data

pyscroll can be used with existing map data, but you will have to create a class to interact with pyscroll
or adapt your data handler to have these functions / attributes:

class MyData:
def __init__(self, tmx):
self.default_image = generate_default_image((tmx.tilewidth, tmx.tileheight))

def tilewidth(self):
Return pixel width of map tiles

def tileheight(self):
Return pixel height of map tiles

def width(self):
Return number of tiles on X axis

def height(self):
Return number of tiles on Y axis

def visible_layers(self):
Return a list of layer numbers that are visible.
If using a single layer map, just return [0]

def get_tile_image(self, position):
Return a surface for this position.
Return self.default_image if there is not map data for the position.

position is x, y, layer tuple

def convert(self, surface=None, depth=None, flags=0):
Optional. Convert the surfaces to match the display.
File Type Py Version Uploaded on Size (md5) Source 2014-03-30 10KB
  • Downloads (All Versions):
  • 35 downloads in the last day
  • 415 downloads in the last week
  • 735 downloads in the last month