Drawing circle with Pygame is just like drawing a rectangle which I have shown you in the previous post. Let draw a circle on the screen this time with the pygame.draw.circle method. This method takes in the screen surface argument, a tuple consists of the RGB color value for the circle, the tuple consists of the position of the circle on the screen, the radius of the circle as well as an optional line width property which we have previously used in the previous rectangle example! Below is the entire script to draw a solid circle (no outline) on the screen.
import pygame from pygame.locals import * from sys import exit from random import * pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) while True: for event in pygame.event.get(): if event.type == QUIT: exit() screen.fill((255,255,255)) screen.lock() circle_pos = (290, 220) circle_radius = 100 circle_color = (255, 100, 230) pygame.draw.circle(screen, circle_color, circle_pos, circle_radius) screen.unlock() pygame.display.update()
The rest of the script above is almost the same as the previous script which uses to create two rectangle objects.