1
\$\begingroup\$

I tried to display a player image in a 800x600 window using PyGame but when I try it, the window just gets stuck (immovable with mouse drag, minimize,maximize and close button is stuck and not clickable).

I have no Idea for the reason.

Here's the code:

from pygame.locals import *
pygame.init()


fps = pygame.time.Clock()

WINDOW_SIZE = (800, 600)
pygame.display.set_caption("Game")
screen = pygame.display.set_mode(WINDOW_SIZE, 0, 0)

player_image = pygame.image.load("Witch.png")
location = [0,0]

while True:

    screen.blit(player_image, location)

    pygame.display.update()
    fps.tick(60)

pygame.quit()

Please help me where I have made a mistake or what I should do. Thanks in advance.

\$\endgroup\$
1
\$\begingroup\$

You need to handle events regularly. Usually that is calling pygame.event.get(). For example:

while not done: 
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

If you are doing nothing with the events, you can call pygame.event.pump() instead.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy