Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Make a basic pygame window

import pygame # Have to install pygame with 'pip install pygame'
pygame.init() # Initialize pygame

window = pygame.display.set_mode((800, 600)) # Window size
pygame.display.set_caption('Window name')

run = True
while run:
  for event in pygame.event.get():
    if event.type == pygame.QUIT: # If x button on window is pushed
      run = False # Exit while loop
  
  window.fill((255, 0, 0)) # Fill window with red
  pygame.display.update() # Update the window to show the colour red
  
pygame.quit() # Quit pygame
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #Make #basic #pygame #window
ADD COMMENT
Topic
Name
8+9 =