I have defined a "game loop" function, (the code below) but for some reason it doesn't exit upon trying close the window (the "quit event") despite there being code written to break the loop if you do that. I have tried handling the event in question by using a variable to dictate when the loop should run, as well as handling using a break statement to close the loop. neither have worked.
##game loop
def main():
clock = pygame.time.Clock()
run = True
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == quit:
run = False
draw_all()
if __name__ == "__main__":
main()
Here you compare the event type to the predefined quit
function of python. This is obviously never evaluted to True
.
Do instead if event.type == pygame.QUIT:
.