import pygame
import sys
pygame.init()
size= width,height =500,600
screen=pygame.display.set_mode(size)
tu=pygame.image.load("图片地址")
tutu=tu.get_rect()
speed=[5,5]
clock=pygame.time.Clock()
while 1:
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if tutu.right < 0 or tutu.left > width:
speed[0] = -speed[0]
if tutu.top < 0 or tutu.bottom >height:
speed[1]=-speed[1]
tutu=tutu.move(speed)
screen.blit(tu,tutu)
pygame.display.flip()
python之会动的图片
最新推荐文章于 2024-04-09 00:03:59 发布