The examples in this article describe Python-based pygame implementation of a picture instead of a mouse move effect. Share to everyone for your reference, as follows:
Think of the school pygame now a few minutes, wrote a small program: pictures instead of mouse movement
The operation effect of the program:
When the mouse moves to the window, the mouse is gone, instead of the picture .....
The code section is as follows:
#pygame First Programimport pygamefrom pygame.locals import *from sys import exit__author__ = {' name ': ' Hongten ', ' ma Il ': ' hongtenzone@foxmail.com ', ' QQ ' : ' 648719819 ', ' Version ': ' 1.0 '}bg_image = ' c:\\test\\1.gif ' Mouse_ IMAGE = ' c:\\test\\mouse.gif ' pygame.init () #设置窗口的大小screen = Pygame.display.set_mode ((500, 500), 0, 32) Pygame.display.set_caption (' hongten\ ' first Pygame program ') bg = pygame.image.load (bg_image). CONVERT () mouse_cursor = Pygame.image.load (mouse_image). Convert_alpha () while True: For event in Pygame.event.get (): if Event.type = = QUIT: exit () screen.blit (BG, (0, 0)) #鼠标的x, y coordinate x, y = Pygame.mouse.get_pos () #隐藏鼠标 Pygame.mouse.set_visible (False) x-= Mouse_cursor.get_width ()/2 y-= Mouse_cursor.get_height ()/2 # Use other graphics instead of mouse screen.blit (Mouse_cursor, (x, y)) pygame.display.update ()
Full instance code code click here to download this site.
I hope this article is helpful for Python program design.