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

Re: [pygame] Game stutters



R. Alan Monroe wrote:
If the ball's just bouncing around why not do
screen.fill((0,0,0),ballRect)
screen.blit((ballImage,ballRect)
pygame.display.update(ballRect)

I tried that on my box... didn't make any difference. My guess is it's due to not being locked to vsync.

Alan


Yeah, it might not be noticable, and since he's limiting the FPS, I guess it wouldn't be
but if the FPS weren't limited it would be more efficient because it's just updating the areas of the screen that are changed.
although, it's not a correct example because it doesn't cover up what was on the previous frame. My fault.
It should be


screen.fill((0,0,0),prevRect)
screen.blit(ballImage,ballRect)
pygame.display.update([prevRect,ballRect])
prevRect = ballRect

and somewhere at the top before the while loop
prevRect = pygame.Rect((0,0))
I guess.
Anyway, I was just trying to point out that not the whole screen needed updating,
but I'm sure in the actual game there's much more graphics to be taken into consideration,
as he said this was just a simple example without any of hte game code.
Good luck with the game,
I don't see anything that would cause random stoppages.
-Luke