0

I'm trying to make it so that once you press the "X" button on the window it closes. I've followed a tutorial but when it gets to the line:

pygame.quit()

It throws up a

TypeError: 'bool' object is not callable

Anyone know why this is? This is my code:

end = False
events = pygame.event.get()

while not end:
    for event in pygame.event.get():

            if event.type == pygame.QUIT:
                    end = True

    gameDisplay.fill(white)

    print (end)
    pygame.display.update()
    clock.tick(60)

print ("end")
pygame.quit()
quit()

EDIT

This is my program as it stands, still throwing up the same error

intro_text = False
white (225,225,225)
display_width = 1280
display_height = 660
t_lp = 0
text = "game time"
txtSize = 50
myfont= pygame.font.SysFont("Poor Richard",txtSize)
textSurface = myfont.render(text, False, (0,0,0))

while not intro_text:
    gameDisplay.fill(white)
    if t_lp == 0:
            gameDisplay.blit(textSurface, (0.4*display_width, 0.2*display_height))
            pygame.display.update()
    clock.tick(60)


    for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_SPACE:
                            if t_lp == 1:
                                    intro_text = True
                            if t_lp == 0:
                                    gameDisplay.fill(white)
                                    text = "After Trecking through Porky's dungeon, Jabe finally finds the Swine's final lair!"
                                    txtSize = 25
                                    textSurface = myfont.render(text, False, (0,0,0))
                                    gameDisplay.blit(textSurface, (142, 0.5*display_height))
                                    pygame.display.update()
                                    t_lp =1




            if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
ojj920
  • 27
  • 4
  • You don't need to call it at all. From the docs: `When the Python interpreter shuts down, this method is called regardless, so your program should not need it, except when it wants to terminate its pygame resources and continue.` – match Jan 23 '18 at 20:51
  • 1
    Please post a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve). The code snippet that you've posted should work correctly. How do you run the program and what operating system, Python and pygame version do you use? – skrx Jan 23 '18 at 22:34
  • 1
    As @skrx mentioned, there is nothing inherently wrong with the code above. My bet is that you named a variable something like `quit` and assigned it a boolean value. However, I cannot tell for sure unless you post a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve). – Micheal O'Dwyer Jan 24 '18 at 12:07
  • only just saw this, the program has changed quite a bit since i made this post, but Ill show you the bits thats relevant – ojj920 Jan 25 '18 at 21:47

0 Answers0