pygame.display.set_caption('Crash!')
window = pygame.display.set_mode((300, 300))
running = True
Rectplace = pygame.draw.rect(window, (255, 0, 0), (100, 100, 100, 100))
pygame.display.update()
while running:
    pos = pygame.mouse.get_pos()
pressed1, pressed2, pressed3 = pygame.mouse.get_pressed()
if Rectplace.collidepoint(pos) & pressed1 == 1:
    print('You have opened a chest!')
for event in pygame.event.get():
    if event.type == pygame.QUIT:
        running = False
Pygame mouse clicking detection