[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] blit speedup



I've made a tiling engine where tiles are stored as list of subsurfaces from a texture surface, and the game map is stored as a list of tile indices.  The problem is that I'm ending up with some slowdown even at low resolutions.  I was wondering if anyone's run into this before and could offer suggestions.  The code I have in the map draw() function is:

    for i in self.tiledata: # i is an integer, tiledata is a standard list right now, will convert to an array for speed as the next step
        surf = dat[i]
        sys.screen.blit(surf, (i, i)) # I would use real coordinates, the i, i is just for speed testing

In particular:
    (a.) is there a way to speed up surface.blit()?  I've already used surface.convert(), and from some of the tutorials hardware surfaces sound problematic.
    (b.) Is there a way to call the blit function from inlined C code?  I've seen the SciPy.blitz examples showing a massive speedup on similar loops by doing this.

Thanks in advance!