[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Losing the background image



Hi everyone.

I'm new to both Python and PyGame but I love them both very much. I
just starter playing around with PyGame/SDL basics and I wrote the
following script (relevant parts only):


----------------------------------------------------------------
#
# Initialisation
#

pygame.init()

mainSurface = pygame.display.set_mode( (800,600),
HWSURFACE|DOUBLEBUF|FULLSCREEN, 32 )

bgSurface = pygame.image.load("background.png").convert(mainSurface)
spriteSurface =
pygame.image.load("sprite.png").convert_alpha(mainSurface)

dirty_rects = [];
i = 0;

#
# First two cycles of the animations : we'll collect
# dirty rects for both the surfaces
#

mainSurface.blit(bgSurface, (0,0))
dirty_rects.append(mainSurface.blit(spriteSurface, (startx,250)))
pygame.display.flip()
mainSurface.blit(bgSurface, (0,0))
dirty_rects.append(mainSurface.blit(spriteSurface, (startx+1,250)))
pygame.display.flip()

# Main cycle

for x in range(startx+2,700,4):
    # Background restoring
    mainSurface.blit(bgSurface, dirty_rects[i], dirty_rects[i])

    # Sprite blitting
    dirty_rects[i] = mainSurface.blit(spriteSurface,
(x,250+50*math.sin(3.1415*x/100)))
    i = (i+1) % 2
    pygame.display.flip()
    pygame.time.delay(20)

----------------------------------------------------

We should know that the backgroung image ("background.png") covers the
whole framebuffer and the sprite ("sprite.png") uses a pixel-based
alpha channel as set up by Photoshop.

The problem is that, for a while the animation behaves well but
suddenly I loose the background on one of the surface of the double
buffer leaving a white background canvas. This happens only on one of
the two surfaces making blinking the part of the background that were
not restored after a sprite passage.

The problem doesn't occur if I set up a windowed video mode (not
FULLSCREEN).

Why ? Did you experimented the same problem ?

My system is a Win2k Professional Edition with no Service Pack
installed and a G400 32Mb not Dual Head. I don't know the version of
DirectX currently installed.

Please help.

Cristiano
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org