一个小程序:图片代替鼠标移动
生活随笔
收集整理的這篇文章主要介紹了
一个小程序:图片代替鼠标移动
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一個小程序:圖片代替鼠標移動
程序的運行效果:
當鼠標移動到窗口內,鼠標不見了,取而代之的是圖片.....
==============================================
代碼部分:
==============================================
#pygame first programimport pygame from pygame.locals import * from sys import exit__author__ = {'name' : 'liuzhi','mail' : '646557623@qq.com','blog' : 'http://www.cnblogs.com/liuzhi','QQ' : '646557623','Version' : '1.0'}BG_IMAGE = 'D:\\python\\test1\\1.gif' MOUSE_IMAGE = 'D:\\python\\test1\\mouse.gif'pygame.init()#設置窗口的大小 screen = pygame.display.set_mode((500, 500), 0, 32) pygame.display.set_caption('hello liuzhi')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坐標x, y = pygame.mouse.get_pos()#隱藏鼠標 pygame.mouse.set_visible(False)x -= mouse_cursor.get_width() / 2y -= mouse_cursor.get_height() / 2#用其他圖形代替鼠標 screen.blit(mouse_cursor, (x, y))pygame.display.update()?源碼位置http://files.cnblogs.com/liuzhi/test1.zip
?
轉載于:https://www.cnblogs.com/liuzhi/p/3975730.html
總結
以上是生活随笔為你收集整理的一个小程序:图片代替鼠标移动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: “放到桌面”的Servlet实现
- 下一篇: 矩阵快速幂---BestCoder Ro