Below is the basic pygame application. You'll want to remember how to make it.
import pygame # imports the module
# RESIZABLE is only needed if you want a resizable window
from pygame import RESIZABLE
# initializes imported pygame modules, always needed when using pygame
pygame.init()
# creates resizable pygame window that is 500 pixels wide and 400 high
# sets the caption of the window to "My first pygame app!"
flag = RESIZABLE
window = pygame.display.set_mode((500, 400), flag)
pygame.display.set_caption("My first pygame app!")
# this is where the game loop begins
run = True
while run:
for event in pygame.event.get():
# checks if the close button is pressed
# if so, exit the game loop
if event.type == pygame.QUIT:
run = False
# deactivates pygame modules, opposite of pygame.init()
pygame.quit()
View code on GitHub.
Running this program will create a resizable black window that is 500 pixels wide and 400 pixels tall.
flag to RESIZABLE, which we imported. It is called 'flag' because pygame.display.set_mode can take from 1 to 5 parameters. The first parameter is necessary and is a tuple/list of height and width, and the second option parameter is any "flags" (such as if the window should be resizable or not); these flags should be pygame.(flag).pygame.Surface) returned by pygame.display.set_mode.pygame.init()), you should still use it at the end of your code.