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

Re: [pygame] Alpha Channel



what you describe sounds like it might be that the background isn't
getting cleared below the ship - so when it draws on top of itself, it
eventually fills the partially transparent area with alpha.

here's some code that shows that happening (press space to toggle if
it erases the background)

import pygame
import sys

def main():
	pygame.init()
	
	screen = pygame.display.set_mode((640, 480))
	image = pygame.image.load("ship2.png").convert_alpha()
	erase = False
	
	while 1:
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				sys.exit()
			elif event.type == pygame.KEYDOWN:
				if event.key == pygame.K_ESCAPE:
					sys.exit()
				elif event.key == pygame.K_SPACE:
					erase = not erase
		if erase:
			screen.fill((0,0,0))
		screen.blit(image, (0,0))
		pygame.display.flip()

if __name__ == '__main__':
       main()



On 4/20/06, AMMayberry1@xxxxxxxxxxxx <AMMayberry1@xxxxxxxxxxxx> wrote:
> The .png image file is attached. The white sections that are over the wood-textured part of the image are showing up fine. The white sections that stick out beyond the main part of the image on top and bottom are showing up as solid white, squares, instead of the way they are shown in the image. Also, I've discovered something else. When another surface is blitted near the top white sehttp://webmail.netscape.com/compose.adp
> Sendction, the white square disappears, at least partially, and the correct image appears underneath. I haven't tried it with the bottom white section.
>