Just a noob question about python and pygame event handling.
I got the following code in a pygame tutorial:
while 1:
for event in pygame.event.get():
if event.type in (QUIT, KEYDOWN):
sys.exit()
...but for some reason it returns this error:
if event.type in (QUIT, KEYDOWN):
NameError: name 'QUIT' is not defined
Can anyone explain this?
I think you meant this:
if event.type in (pygame.QUIT, pygame.KEYDOWN)
The tutorial probably used from pygame import *, and this example perfectly shows why this is a bad habit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With