cool hit counter pygame series_bouncy ball_Intefrankly

pygame series_bouncy ball


Here's the bouncy ball written by pygame

Running effect.

Code section.

 1 #A bouncing ball
 2 
 3 import sys, pygame
 4 
 5 __author__ = {'name' : 'Hongten',
 6               'mail' : 'hongtenzone@foxmail.com',
 7               'blog' : 'http://www.cnblogs.com/hongten',
 8               'QQ'   : '648719819',
 9               'Version' : '1.0'}
10 
11 pygame.init()
12 
13 size = width, height = 600, 500
14 speed = [1, 1]
15 black = 249, 130, 57
16 
17 screen = pygame.display.set_mode(size)
18 
19 ball = pygame.image.load('c:\test\ball.gif')
20 ballrect = ball.get_rect()
21 
22 while 1:
23     for event in pygame.event.get():
24         if event.type == pygame.QUIT:
25             sys.exit()
26 
27     ballrect = ballrect.move(speed)
28     if ballrect.left < 0 or ballrect.right > width:
29         speed[0] = -speed[0]
30     if ballrect.top < 0 or ballrect.bottom > height:
31         speed[1] = - speed[1]
32 
33     screen.fill(black)
34     screen.blit(ball, ballrect)
35     pygame.display.flip()

Recommended>>
1、Update on the School of Artificial Intelligence at NTU 60100 undergraduates to be enrolled two specializations to be offered
2、A comprehensive analysis of recently exposed attacks against banks SWIFT systems
3、The core tenets of infographic creation
4、JSON manipulation in java
5、expressnodethrowingerroronmongodb

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

    已发送

    朋友将在看一看看到

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

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号