pygame系列_第一个程序_图片代替鼠标移动
2013-10-09 22:15
330 查看
想想现在学校pygame有几个钟了,就写了一个小程序:图片代替鼠标移动
程序的运行效果:
当鼠标移动到窗口内,鼠标不见了,取而代之的是图片.....
==============================================
代码部分:
==============================================
你也可以试试,源码下载:http://files.cnblogs.com/hongten/pygame_first_program.rar
程序的运行效果:
当鼠标移动到窗口内,鼠标不见了,取而代之的是图片.....
==============================================
代码部分:
==============================================
#pygame first program import pygame from pygame.locals import * from sys import exit __author__ = {'name' : 'Hongten', 'mail' : 'hongtenzone@foxmail.com', 'blog' : 'http://www.cnblogs.com/hongten', '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\'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)) #鼠标的x,y坐标 x, y = pygame.mouse.get_pos() #隐藏鼠标 pygame.mouse.set_visible(False) x -= mouse_cursor.get_width() / 2 y -= mouse_cursor.get_height() / 2 #用其他图形代替鼠标 screen.blit(mouse_cursor, (x, y)) pygame.display.update()
你也可以试试,源码下载:http://files.cnblogs.com/hongten/pygame_first_program.rar
相关文章推荐
- 一个小程序:图片代替鼠标移动
- Python基于pygame实现图片代替鼠标移动效果
- Python基于pygame实现图片代替鼠标移动效果
- Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序
- 用鼠标拖动图片移动
- JQuery实现鼠标移动图片显示描述层的方法
- 移动鼠标实现图片的缩放
- JS与CSS3实现图片响应鼠标移动放大效果示例
- javascript实现图片跟随鼠标移动效果的方法
- 鼠标移动到某文字上然后显示图片
- supermap学习系列(五)——上一篇的续集(鼠标单击或者移动,高亮显示并弹出对话框)
- 鼠标在文本上移动时层的显示与消失(以及层里显示图片)ASP.NET
- 鼠标移动观看图片效果(swf在文件中)
- Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序
- jQuery鼠标移动图片上实现放大效果
- 利用热键控制鼠标移动的一个程序
- 跨平台移动开发phonegap/cordova 3.3全系列教程-图片上传
- 使用jQuery实现鼠标滑过图片移动特效
- JQuery实现鼠标移动到图片上显示边框效果
- FMS3系列(一):第一个FMS程序,连接到FMS服务器(Flash/Flex两种实现)