"""
Created on Tue May 4 09:53:29 2021
@author: 豪哥
"""
import pygame
from sys import exit
pygame.init()
size=width,height=880,600
scree=pygame.display.set_mode(size)
pygame.display.set_caption('流浪地球')
ball=pygame.image.load(r"D:/笔记截图/Camera Roll/TE2.png")
ballrect= ball.get_rect()
speed=[5,5]
angle=5
clock=pygame.time.Clock()
while True:
clock.tick(30)
for i in pygame.event.get():
if i.type == pygame.QUIT:
pygame.quit()
exit(1)
ballrect=ballrect.move(speed[0],speed[1])
newball=pygame.transform.rotate(ball,angle)
angle += 3
newp=newball.get_rect()
newp.left,newp.top=ballrect.left,ballrect.top
if newp.left<0 or newp.right>800:
speed[0]=-speed[0]
if newp.top<0 or newp.bottom>600:
speed[1]=-speed[1]
background = pygame.image.load(r"D:\笔记截图\Camera Roll\TE3.png")
scree.blit(pygame.transform.scale(background,size),(0,0))
scree.blit(newball,ballrect)
pygame.display.update()
pygame.display.flip()