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()