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

Re: [pygame] Scrolling

I am using this sort of scrolling, blitting the part of the background that appears on the screen, then the objects, but the updates are a bit truncated. I've profiled the game and there is no processing bottleneck as far as I analysed.

After doing some research, I found that this truncation could be caused by lack of synchronization between the monitor's update and the clock.tick() FPS limiter. Changing the tick paramater did not make any difference though, even with values as low as 2 (one update every half second) and as high as the monitor's update frequency (60 in my case).

If someone knows a fix/workaround for this issue, I'd be grateful to hear it.

On Mon, Aug 3, 2009 at 12:56, Fiona Burrows <fiona@xxxxxxxxxxxxxxxxxxx> wrote:

Yanom Mobis wrote:
How is scrolling tipicallly done in pygame? I was thinking of creating a large surface, blitting all the game objects to that surface, and then blitting part of that surface to the screen. like this:

That's kinda what I do.
I blit part of the background directly to the screen and then blit all game objects to the screen. There's no real need for a large intermediary surface. Unless you want to do something like scaling/rotation on the whole thing.

Unfortunately it is slow as hell.
Depending on the nature of game you could attempt some form of dirty rectangles to reduce the amount of blitting going on, but it's usually not worth it if there's a lot of scrolling going on.