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

Re: [pygame] stupid question



hi again
Take a look at that load_image function. It is loading a non-transparent image from a BMP and then adding colorkey transparency to it. There is nothing special you need to do. Call Surface.set_colorkey() with the color you want to be transparent. That's it.

i must be doing something veru stupid somewhere because it doesnt do it properly.

class drawSprite():
def __init__(self, bgcolor, height, width):
self.image = pygame.Surface((height, width)).convert()
self.image.set_colorkey(bgcolor, pygame.RLEACCEL)
self.image.fill(bgcolor)

self.color = library.randomRGB()
for x in range(4) :
self.pts.append(library.randomPoint(height, width))
pygame.draw.polygon(self.image, self.color, self.pts, 0)

To render the surface on the stage I am deleting the image (fill with background color its old position on screen), I calculte the new rect and then I blit the self.image again on to the screen surface. Finally I update the rects.

I have another example where I use an imported image. I just realised that they are transparent to the screen, so if i change the background color they keep transparent but if I move one on top of the other they are actually not transparent and they cover the other images. So rather their transparent areas have the color of the background.

any ideas about what could i be doing wrong? or maybe i need some more complex system?

thanks again!

--
enrike