Python Games first lesson

Source: Internet
Author: User

This code is used to display a picture
1 #-*-coding:utf-8-*-2 ImportPygame#Import Pygame Library3 fromSysImportExit#borrowing the exit function from the SYS module to exit the program4Pygame.init ()#Initialize Pygame5 6Screen = Pygame.display.set_mode ((600,170), 0,32)7 #Create a window, the first parameter is Ganso, represents the resolution, the second is the flag bit, the default 0, if it is fullscreen, it is full screen, the third is the color depth8Pygame.display.set_caption ("Hello world!")#Set Window caption9Background = Pygame.image.load ('A.png'). CONVERT ()#load and convert imagesTen One whileTrue: A forEventinchpygame.event.get (): - ifEvent.type = =Pygame. QUIT: - pygame.quit () the exit () -Screen.blit (background, (0,0))#draw the background image, the first parameter is the Surface object, the second argument is the upper left corner of the sitting - -Pygame.display.update ()#Refresh Screen

Python Games first lesson

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.