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.
What you’ll see:
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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).