Super Simple Pygame Window

If you’ve already installed pygame, let’s create a super simple Pygame window, that, for now, does nothing! We explain the code in detail below.

download-bttn
Download Code

What you’ll see:

simple-pygame-window

Code

import pygame

pygame.init()
width = 350
height = 200

#make the pygame window
pygame.display.set_mode((width, height ) )

running = True

while (running):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

This simply creates a window and that’s it.

And otherwise just initialize pygame (line 3) , creates the simple window (line 8) and uses the classic pygame loop. We’ll delve into the code more soon.

In the next tutorial, we’ll  begin adding some simple functionality (add an image to a surface).