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

Re: [pygame] Smooth scrolling ?



Hi Dmitry,

It is working very smooth on my PC at least.
Another thing that I found out when doing my football field demo a few years ago (see http://aspn.activestate.com/ASPN/Mail/Message/pygame-users/1446979) that DOUBLEBUF and HWSURFACE have meaning only in FULLSCREEN mode.


Try it out :)

Guillaume

Dmitry Borisov wrote:

Guys,
I'm just about to give up on smooth scrolling with pygame. I tried many different ways but getting jerky motions no matter what I do.
The code is below and it simply blits the pic on a screen and flips the screen when the vsync backtrace is up. Then it repeats. In my assumption it should be smooth, but it is not :(
Any helping hand ?
Thanks a lot,
Dmitry/
pygame-1.6
WinXP, P4-1.8
# ----------------------------------------------------------------------------


import pygame
pygame.init()
screen= pygame.display.set_mode( (800,600), pygame.DOUBLEBUF|pygame.HWSURFACE, 32 )
i= 0
f= pygame.font.Font( 'data/arialn.ttf', 80 )
s= f.render( 'Scrolling', 1, (0xff,0xee,0x00) )
surf= pygame.Surface( s.get_size(), pygame.SRCALPHA, 32 )
surf.blit( s, (0,0) )
screen.fill( (255,255,255) )
pygame.display.update()
while i< 800:
screen.fill( (255,255,255), (0,200,800,surf.get_height()) )
screen.blit( surf, ( i, 200 ) )
pygame.display.flip()
pygame.event.poll()
i+= 1
pygame.quit()
# ----------------------------------------------------------------------------