Python game pygame Module Drawing Circle and moving method introduction

Source: Internet
Author: User

1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 #Author:ss4 5 ImportPygame6 ImportSYS7 8 #Initialize9 Pygame.init ()Ten  OneSize = Width,height = 1000,600#Set Screen Size ABLUE = 0,0,255 -White = 255,255,255 -BLACK =0,0,0 theRED = 255, 0,0 -GREEN = 0,255, 0 -  -Screen = Pygame.display.set_mode (size)#Create a Surface object +Pygame.display.set_caption ('drawing round and dragging')#Create a title -  + #Center Position Definition APosition = size[0]//2, size[1]//2 at  -moving =False -  -  whileTrue: -      forEventinchpygame.event.get (): -         ifEvent.type = =Pygame. QUIT: in sys.exit () -         ifEvent.type = = Pygame. Mousebuttondown:#get mouse click events to             ifEvent.button = = 1:#Click the left mouse button +moving =True -         ifEvent.type = = Pygame. Mousebuttonup:#get release mouse event the             ifEvent.button = = 1:#release the left mouse button *moving =False $     ifMoving:Panax NotoginsengPosition = Pygame.mouse.get_pos ()#Update Center position is the current position of the mouse -  the  +  AScreen.fill (White)#Fill Screen the     #draw a circle of various size colors +Pygame.draw.circle (screen,blue,position,30,1)  -Pygame.draw.circle (screen, BLACK, Position, 50, 1) $Pygame.draw.circle (screen, RED, Position, 80, 1) $Pygame.draw.circle (screen, GREEN, position, 120, 1) -     #Refresh Screen -Pygame.display.flip ()

Python game pygame Module Drawing Circle and moving method introduction

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.