python - Pygame Screen tearing when moving line across screen -


i trying move image:

enter image description here

across pygame screen, right left , again, image moves, every second or have flicker of screen tear make way image so:

enter image description here

the code using loop similar this:

screen.blit(img, (x,y)) pygame.update((x,y),(w,h)) pygame.draw.rect(screen,(0,0,0),((x,y),(w,h))) 

so far have tried following solve issue:

using hwsurface, fullscreen, doublebuf flags when creating screen, had no effect, adjusted .update(rect) .flip() (as recommended when using doublebuf?)

splitting memory between gpu , cpu (i running on raspberry pi 2) have tried giving both more memory, no change.

setting clock.tick throttle update rate 60 fps (above , below well) did smooth out of tearing not all

adjusting size of each increment left or right, making increments smaller results in less tearing, less speed. (can't have going too slow)

blitting new black surface rather drawing black rect on previous position (when moving image ensure there no trail behind it) read somewhere blit better supported hwsurface drawing, although can't confirm this? - had no effect

if has other solutions may improve situation i'd grateful.

i rather not change pygame else (like pyglet) have done quite lot of implementation far using pygame, open suggestions.

cheers

edit

relevant code requested:

if scanner == true:     clocker.tick(clockspeed)     if x < 11:         slower = 3         if firsttime == true:             img.set_alpha(int(x * 25))             newsurf.set_alpha(int(x * 25))             screen.blit(newsurf,(xtext,35))             pygame.display.update((xtext,35),((xtext + newsurf.get_width()),(50 + newsurf.get_height())))             img.set_alpha(255)      elif x > (divider - 15):         slower = 3     else:         slower = 0         firsttime = false      screen.blit(img, ((xstart - (x * increment) + slower),100))     pygame.display.update(((xstart - (x * increment) + slower),100),(95,450))     pygame.draw.rect(screen, (0,0,0), (((xstart - (x * increment) + slower),100),(95,450))) 

the slower variable give feel of inertia bar reaches far left , right sides of sweep across speed slow down little.

the firsttime variable fading in bar when first appears.

there loop below similar, sweeps image other way.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -