![]() ![]() Line 8 sets up your program’s display window. Lines 4 and 5 import and initialize the pygame library. Let’s break this code down, section by section: When you run this program, you’ll see a window that looks like this: fill (( 255, 255, 255 )) 21 22 # Draw a solid blue circle in the center 23 pygame. QUIT : 17 running = False 18 19 # Fill the background with white 20 screen. set_mode () 9 10 # Run until the user asks to quit 11 running = True 12 while running : 13 14 # Did the user click the window close button? 15 for event in pygame. init () 6 7 # Set up the drawing window 8 screen = pygame. You can get all of the code in this article to follow along:ġ # Simple pygame program 2 3 # Import and initialize the pygame library 4 import pygame 5 pygame. pygame works with most versions of Python, but Python 3.6 is recommended and used throughout this article. ![]() A basic understanding of object-oriented Python is helpful as well. You should also be familiar with how to open files on your platform. This primer assumes you have a basic understanding of writing Python programs, including user-defined functions, imports, loops, and conditionals.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |