黄粉虫价格,高跟单鞋,23度QQ站
本文实例讲述了Python基于pygame实现的弹力球效果。分享给大家供大家参考,具体如下:
运行效果:
代码部分如下:
#A bouncing ball import sys, pygame __author__ = {'name' : 'Hongten', 'mail' : 'hongtenzone@foxmail.com', 'QQ' : '648719819', 'Version' : '1.0'} pygame.init() size = width, height = 600, 500 speed = [1, 1] black = 249, 130, 57 screen = pygame.display.set_mode(size) ball = pygame.image.load('c:\\py\\ball.png') ballrect = ball.get_rect() while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() ballrect = ballrect.move(speed) if ballrect.left < 0 or ballrect.right > width: speed[0] = -speed[0] if ballrect.top < 0 or ballrect.bottom > height: speed[1] = - speed[1] screen.fill(black) screen.blit(ball, ballrect) pygame.display.flip()
完整实例代码代码点击此处。
希望本文所述对大家Python程序设计有所帮助。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python 实现将numpy中的nan和inf,nan替换成对应的均值
python爬虫把url链接编码成gbk2312格式过程解析
网友评论