Drawing Rectangles In Pygame
pygame.draw
Can use to draw,
- rectangles
- circles
- lines
- points
- ellipses etc.
Drawing Rectangles
pygame.draw.rect(display to draw, color, rectangle)
pygame.draw.rect(display to draw, color, rectangle, line width, border radius)
pygame.draw.rect(screen, 'Pink', text_rectangle)
Drawing Lines
pygame.draw.line(surface, color, start position(x,y), end position(x,y), width)
# a line from top left corner to bottom right corner
pygame.draw.line(screen, 'Black', (0,0), (576,400), 5)
# a line that follows the mouse
pygame.draw.line(screen, 'Black', (0,0), pygame.mouse.get_pos() , 5)
Drawing Ellipses
pygame.draw.line(surface, color, rectangle, width)
# drawing a elliplse in a new rectangle
pygame.draw.ellipse(screen, 'Brown', pygame.Rect(50,200,100,100))