本帖最后由 一个账号 于 2020-3-28 14:12 编辑
改成这样:
import pygame
import sys
pygame.init()
size = width,height=1200, 750
speed=[-2,1]
clock = pygame.time.Clock()
bg = (255,255,255)
screen = pygame.display.set_mode(size)
pygame.display.set_caption('123')
turtle = pygame.image.load('蓝色.png')
position = turtle.get_rect()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
position.left += speed[0]
position.top += speed[1]
if position.left < 0 or position.right > width:
turtle = pygame.transform.flip(turtle,True,False)
speed[0]=-speed[0]
if position.top < 0 or position.bottom > height:
speed[1]=-speed[1]
screen.fill(bg)
screen.blit(turtle,position)
pygame.display.flip()
pygame.time.delay(1)
clock.tick(200)
|