Python Project Practice One (alien invasion) first article

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.