cool hit counter pygame series_first_program_picture_instead_of_mouse_movement_Intefrankly

pygame series_first_program_picture_instead_of_mouse_movement


Think about the school pygame now has a few clocks, and wrote a small program:picture instead of mouse movement

The program works as follows.

When the mouse moves inside the window, the mouse disappears and is replaced by the image .....

==============================================

Code section.

==============================================

 1 #pygame first program
 2 
 3 import pygame
 4 from pygame.locals import *
 5 from sys import exit
 6 
 7 __author__ = {'name' : 'Hongten',
 8               'mail' : 'hongtenzone@foxmail.com',
 9               'blog' : 'http://www.cnblogs.com/hongten',
10               'QQ'   : '648719819',
11               'Version' : '1.0'}
12 
13 BG_IMAGE = 'c:\test\1.gif'
14 MOUSE_IMAGE = 'c:\test\mouse.gif'
15 
16 pygame.init()
17 
18 # Set the size of the window
19 screen = pygame.display.set_mode((500, 500), 0, 32)
20 pygame.display.set_caption('Hongten's First Pygame Program')
21 
22 bg = pygame.image.load(BG_IMAGE).convert()
23 mouse_cursor = pygame.image.load(MOUSE_IMAGE).convert_alpha()
24 
25 while True:
26     for event in pygame.event.get():
27         if event.type == QUIT:
28             exit()
29 
30     screen.blit(bg, (0, 0))
31     # mouse-basedx,y coordinates
32     x, y = pygame.mouse.get_pos()
33     # Hide Mouse
34     pygame.mouse.set_visible(False)
35 
36     x -= mouse_cursor.get_width() / 2
37     y -= mouse_cursor.get_height() / 2
38 
39     # Replacing the mouse with other graphics
40     screen.blit(mouse_cursor, (x, y))
41 
42     pygame.display.update()

You can also try, source code download.http://files.cnblogs.com/hongten/pygame_first_program.rar

E | hongtenzone@foxmail.com B |http://www.cnblogs.com/hongten


Recommended>>
1、Understanding the relationship between EOS and EOS project tokens to help you invest better
2、CyberVein The Blockchain 30 Solution
3、Talos This is a serious Windows bug Microsoft calm down its not that serious
4、Demystifying blockchain I why blockchain is so hot
5、Stanford Artificial intelligence rediscovers periodic table of elements in a few hours

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号