Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Importing and Initializing

In this lesson, you’ll start writing the code for your game. To start, create a new file named sky_dodge.py. Your first step will be importing pygame, and then you’ll also need to initialize it. This allows pygame to connect its abstractions to your specific hardware:

 1 # Import the pygame module
 2 import pygame
 4 # Import pygame.locals for easier access to key coordinates
 5 # Updated to conform to flake8 and black standards
 6 from pygame.locals import (
 7     K_UP,
 8     K_DOWN,
 9     K_LEFT,
10     K_RIGHT,
11     K_ESCAPE,
12     KEYDOWN,
13     QUIT,
14 )
16 # Initialize pygame
17 pygame.init()

For more information about the local constants, check out the pygame documentation. For more information about the Flake8 and Black coding formatters, check out the following resources:

Become a Member to join the conversation.