1

I just want to know the difference between .quit and .QUIT in pygame. I've tested both but I continue to not understand how they work.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174

2 Answers2

3

QUIT is the enumerator constant for an event type (see event module). The quit event occurs when the pygame window is closed:

for event in pygame.event.get():
    if event.type == pygame.QUIT:
        # [...]

quit() is a function which uninitialize all pygame modules. This function should be called at the end of the applicaiition:

# initialize all imported pygame modules
pygame.init()

# application loop
while True:
    # [...]

# uninitialize all pygame modules
pygame.quit()
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
0

The .QUIT in pygame is used to check if you pressed the cross button on the window which is a pygame event. If you have to quit a window you should press the cross button most of the times.

enter image description here Here is a example of an image for with the cross button on a window

So when you press the cross arrow button on the window it quits the window so when you press the cross button on a pygame window it is stored in a event named pygame.QUIT.

pygame.quit() uninstializez all of pygame's modules i am not sure but after you say nthe line pygame.quit() you wont be able to use most of or all pygame function

Arkodeep Ray
  • 174
  • 14