basic pygame window 1

basic pygame window

import pygame
pygame.init()

WIDTH, HEIGHT = 500, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Hello World!")

run = True
while run:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      run = False
      break

pygame.quit()

Here is what the above code is Doing:
1. We import the pygame module.
2. We initialize pygame.
3. We create a window and give it a title.
4. We create a loop that will run until the user quits the game.
5. We check if the user has quit the game.
6. We quit pygame.

Similar Posts