pygame hello

pygame python is a game library, used to make games

pygame need to install their own

 

Tutorial : https://blog.csdn.net/zha6476003/article/details/82940350

This tutorial contains three instances hello, collision balls, flappy bird

And introduces the basic usage in the instance of some pygame

The official document: http://www.pygame.org/docs/

 

This section describes how to create structure and steps are based on pygame window

Import the pygame
 Import SYS 

pygame.init ()   # initialize the pygame 
size = width, height = 320., 240   # Set Window Size 
Screen with pygame.display.set_mode = (size)   # display window 

the while True:   # dead cycle to ensure the window is always displayed 
    for Event in pygame.event.get ():   # traversing all events 
        IF event.type == pygame.quit:   # If you click to close the window, then quit 
            sys.exit () 

pygame.quit ()   # exit pygame

Structure : Initialization -> Show -> main loop -> Exit

Most of the language to create a window of communication

pygame is driven using the respective message window

 

Detailed

pygame.init () to initialize the application pygame

with pygame.display.set_mode () to display the window

pygame.event.get () is used to obtain a list of message

Get the type of message event.type

pygame.QUIT representation quit message

sys.exit used to exit the python program

Guess you like

Origin www.cnblogs.com/jawide/p/11520715.html