Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Rect is not transparent

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Zed McJack   Members   

349
Like
0Likes
Like

Posted 04 November 2012 - 03:56 PM

I changed the backgroud for MyPong from black to red just to show you that Rectangle of the ball is not transparent.
I looked at web, there is transparency, but it affects all picture not just corners. For that I suppose I will need Sprite class from Pygame, but I wanted to check if there is any solution for this, before moving to sprites.

Z
Ups I didnt post any code so:
[source lang="python"]def draw_circle(radius, color): size = radius*2 pict = pygame.Surface((size, size)) pygame.draw.circle(pict, color, (radius, radius), radius) return pict, pict.get_rect()ball, ball_rect = draw_circle(10, [0, 100, 50])[/source]

Attached Thumbnails

  • Pong-ball.jpg

Edited by Zed McJack, 06 November 2012 - 05:35 AM.


#2 Zed McJack   Members   

349
Like
0Likes
Like

Posted 06 November 2012 - 05:39 AM

Ok, I found solution.
Its not Rect, the Surface is the solution as Rect is drawn onto a Surface and you can set colorkey for transparency so I added.
ball.pict.set_colorkey((0,0,0))


and it worked

Z.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.