Python graphics question:pixel scrolling

Paul Boddie paul at boddie.org.uk
Fri Aug 29 11:40:29 EDT 2008


On 29 Aug, 16:57, Raymond Luxury-Yacht <rlya... at gmail.com> wrote:
> The code below works, and uses pygame for the graphics.  But the scrolling is
> quite flickery when using large windows.  I'm sure that the code
> contains various neophyte python errors, and I'd appreciate any
> comments on that, but my main question is how I ought to have coded it
> in order to have the scrolling be smooth.  I did see a comment on a
> pygame site saying that pygrame should not be used for side-scrollers,
> to which this is similar.  Is there a better way with python?

There are "side-scrollers" written in Python including impressive
games like these:

http://www.pygame.org/project/406/
http://www.pygame.org/project/381/

I see that you're using the surfarray module, which is probably what
you want to do if you're accessing the screen at a pixel level (as
opposed to blitting sprites). My experiences with Numeric/numpy and
Pygame are limited to recolouring bitmaps, but it's certainly possible
to refresh a reasonable size of surface at a decent rate on reasonably
fast hardware. One important hint whose relevance I'm not sure about
here is that you should attempt to avoid frequent format and bit depth
conversions; for sprites and images this usually involves converting
them to the same format as the display surface, but I can imagine that
there may be implications for surfarrays, too.

I hope this gives you some ideas, anyway.

Paul



More information about the Python-list mailing list