1# make the x position, y position, width and the height of the rectangle
2x_pos = 20
3y_pos = 20
4width = 50
5height = 50
6
7# make the rectangle variable
8rectangle = pygame.Rect(x_pos, y_pos, width, height)
9
10# now add this to a surface, add a colour and the rectangle and make it a function
11def make_rect():
12 pygame.draw.rect(surface, (RGB colour in this tuple), rectangle)
13
14
15# after this add it to your infinite loop
16run = True
17while run:
18 for event in pygame.event.get():
19 if event.type == pygame.QUIT:
20 run = False
21
22 make_rect()
23 pygame.display.update()
1# rectangle colour
2rect_colour = (RGB VALUE)
3
4# define the x, y, width & height for the rectangle
5x_position = 30
6y_position = 30
7rect_width = 60
8rect_height = 60
9
10# draw the rectangle
11pygame.draw.rect(screen, rect_colour, pygame.Rect(rect_width, rect_height))