How to draw cirle / ball objects in PyGame


There is a lack documentation about how to draw circle or ball in Pygame. Here is an example taken from my game source code:

1
2
3
4
5
6
self.ball = pygame.Surface((25, 25))
self.ballrect = pygame.draw.circle(self.ball, (0, 255, 0), (15 / 2, 15 / 2), 15 / 2)
self.ball = self.ball.convert()
self.ball.set_colorkey((0, 0, 0))
self.ballrect.topleft = [0, 0]
self.screen.blit(self.ball, self.ballrect)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.