Python learned an intermittent practice, the basic course finally read, and now do three small projects, the first is an alien invasion of the small game:
A Pygame
Pygame is a powerful and fun set of modules that you can use to manage graphics, animations, and even sound, making it easy to develop the games you want.
Two mounting Pygame
Only talk under the Windows System installation Pygame, you can access: https://bitbucket.org/pygame/pygame/downloads/such as:
Find the installer that matches your python and you can't find it: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Download the program is EXE, run it, is the. MHL copy to the project folder, run with Pip:
3 Start Project Game
The Create Pygame window has the appropriate user input code as follows:
Import Sysimport pygamedef run_game (): # Initialize the game and set up a screen object pygame.init () screens = Pygame.display.set_mode (( 1200,800)) pygame.display.set_caption ("Alien invasion") #开始游戏的主循环 while True: # Monitor keyboard and mouse events for Event in Pygame.event.get (): if Event.type = = Pygame. QUIT: sys.exit () # Make the recently painted screen visible pygame.display.flip () run_game ()
F5 Run as:
This is just an empty window, the first step of the game, will slowly add content later, more detailed content can be consulted: Python from the beginning to the practice of this book, today is the first to remember here.
PS: Study for one hours, write a blog for half an hour, time-consuming, this is a lot of people do not want to write the reason it.
Python Project Practice One (alien invasion) first article