TypeError: 'int' object is not callable error when pygame quit button is pressed.

Asked 1 years ago, Updated 1 years ago, 93 views

     for event in pygame.event.get():
        if event.type == pygame.QUIT:
            crashed = True
        elif event.type == pygame.MOUSEBUTTONUP:
            mx, my = pygame.mouse.get_pos()
            if mx > 180 and mx < 340 and my > 200 and my < 330:
                gamepad.fill(WHITE)
                hangman.StartScreen()
                hangman.PreHangMan()
                hangman.main()
            if mx > 500 and mx < 660 and my > 200 and my < 330:
                snakegame.home(0.0)
            if mx > 180 and mx < 340 and my > 440 and my < 580:
                Find the same picture.main()
            if mx > 550 and mx < 660 and my > 440 and my < 580:
                sudoku44.start()
            if mx > 750 and mx < 770 and my > 25 and my < 50:
                pygame.QUIT()
                print("Thank you for enjoying the game so far.")
        elif event.type == pygame.MOUSEBUTTONDOWN:
            mx1, my1 = pygame.mouse.get_pos()
            if mx1 > 750 and mx1 > 770 and my1 > 25 and my1 < 50:
                block6 = pygame.image.load(Exit_2).convert.alpha()

This is how we put the code together. The game runs well, but it ends when you press the quit button, but the phrase "Thank you for enjoying the game so far" is not printed, and the error "TypeError: 'int' object is not callable" is printed. Why?

Traceback (most recent call last):
 File "minigame.py", line 181, in initGame() File "minigame.py",
                     line 179, in initGame runGame()
 File "minigame.py", line 117, in runGame pygame.QUIT()
 TypeError: 'int' object is not callable

python pygame

2022-09-21 22:02

1 Answers

line 117, in runGame pygame.QUIT() TypeError: 'int' object is not callable 

In the pygame.QUIT() part, the error occurred because pygame.QUIT is an int-type variable and is not a function.


2022-09-21 22:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.