Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to create a window in pygame

import pygame
import sys

pygame.init()

width,height = (600,400)
window = pygame.display.set_mode((width,height)) # this makes the window
pygame.display.set_caption('AnyTitle') #this makes a new title for the window

while True:
  for event in pygame.event.get(): #looping through the events in pygame
      if event.type == pygame.QUIT: #checking if the user has clicked the close button
          pygame.quit() # this quits pygame and closes window
          sys.exit() # for smooth closing
 
Source by www.petercollingridge.co.uk #
 
PREVIOUS NEXT
Tagged: #create #window #pygame
ADD COMMENT
Topic
Name
2+2 =