Pygame is opening a not responding window

Ashmeet SIngh

I am creating my first PyGame program.When I run my program a window should PyGame window should open but whenever I run the program a not-responding window is opened.

Here is my code:

import pygame
pygame.init()

screen = pygame.display.set_mode((500,500))

Whenever I run it a not-responding PyGame window opens. How do I fix it?

I have searched the net for solutions but none of them have worked.

Also: When I add pygame.event.get() it opens the window and instantly closes it.

I am using Python 3.9.9 on Visual Studio Code in MacOS

Hồ Quang Vinh

Try this

import pygame
pygame.init()

screen = pygame.display.set_mode((500,500))
black = (0, 0, 0)
running = True
while running:
      print(screen)
      screen.fill(black)
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              running = False
      pygame.display.flip()
      pygame.display.update()
pygame.quit()

in the 'black' variable you can choose another color by going to google and searching for 'rgb color selector' select the color and copy the rgb part

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related