欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python基于pygame實(shí)現(xiàn)圖片代替鼠標(biāo)移動(dòng)效果

 更新時(shí)間:2015年11月11日 11:12:23   作者:Hongten  
這篇文章主要介紹了Python基于pygame實(shí)現(xiàn)圖片代替鼠標(biāo)移動(dòng)效果,可實(shí)現(xiàn)將鼠標(biāo)箭頭轉(zhuǎn)換成圖形的功能,涉及pygame圖形操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了Python基于pygame實(shí)現(xiàn)圖片代替鼠標(biāo)移動(dòng)效果。分享給大家供大家參考,具體如下:

想想現(xiàn)在學(xué)校pygame有幾個(gè)鐘了,就寫了一個(gè)小程序:圖片代替鼠標(biāo)移動(dòng)

程序的運(yùn)行效果:

當(dāng)鼠標(biāo)移動(dòng)到窗口內(nèi),鼠標(biāo)不見(jiàn)了,取而代之的是圖片.....

代碼部分如下:

#pygame first program
import pygame
from pygame.locals import *
from sys import exit
__author__ = {'name' : 'Hongten',
       'mail' : 'hongtenzone@foxmail.com',
       'QQ'  : '648719819',
       'Version' : '1.0'}
BG_IMAGE = 'c:\\test\\1.gif'
MOUSE_IMAGE = 'c:\\test\\mouse.gif'
pygame.init()
#設(shè)置窗口的大小
screen = pygame.display.set_mode((500, 500), 0, 32)
pygame.display.set_caption('Hongten\'s 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))
  #鼠標(biāo)的x,y坐標(biāo)
  x, y = pygame.mouse.get_pos()
  #隱藏鼠標(biāo)
  pygame.mouse.set_visible(False)
  x -= mouse_cursor.get_width() / 2
  y -= mouse_cursor.get_height() / 2
  #用其他圖形代替鼠標(biāo)
  screen.blit(mouse_cursor, (x, y))
  pygame.display.update()

完整實(shí)例代碼代碼點(diǎn)擊此處本站下載。

希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論