Trouble with set_color

Trouble with set_color

Postby dboxall123 » Tue Jul 23, 2013 8:23 pm

Hello everyone. I'm quite new to pygame and I'm trying to make a 'Frogger' game. After searching all over opengameart.com and not finding anything, I searched on Google.I found a lovely little pic of a pixel frog, and saved it as frog.png. Then I wrote this in my code:

Code: Select all
frog=pygame.image.load('frog.png').convert()
frog.set_colorkey(white)


When I blit the image, the white rectangle around the image is still there, but with black dots all over it. So after hunting in the internet, I found a solution that someone had posted:

Code: Select all
frog=pygame.image.load(frog.png)
frog=frog.convert_alpha()
frog.set_colorkey(white)


This has no effect whatsoever, the white rectangle is still there, hasn't even got the black dots in it. Does anyone have any ideas? If there is nothing that I can do, I'll try to draw a basic frog in pygame myself(nothing fancy,just a few rectangles and a couple of circles for eyes). If I do this, how can i assign these drawings to a sprite class?
Thanks
Dan
dboxall123
 
Posts: 108
Joined: Fri Jul 12, 2013 5:28 pm

Re: Trouble with set_color

Postby Mekire » Wed Jul 24, 2013 12:33 am

Could you please link to the image? If the image is on a solid background you can use standard convert() and then set the colorkey to the background color (white or black however are not advisable as you would then be unable to use them in your image). If the background of the image is transparent then you should use convert_alpha() (color key will have no effect on a surface that already contains per-pixel alpha).

-Mek
User avatar
Mekire
 
Posts: 1012
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan


Return to Game Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron