import pygame,sys
from pygame.locals import *
pygame.init()
WINDOWWIDTH=480
WINDOWHEIGHT=700
caption_name='全民飞机大战'
DISPLAYSURF=pygame.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT))
pygame.display.set_caption(caption_name)
Img=pygame.image.load('E:/Microsoft VS Code/python/Pygame/plane Eat plane/images/enemy1.png')#加载图片
FPS=30 #速度
Imgx=400
Imgy=500
fpsClock=pygame.time.Clock()#调用
while True:
Imgx+=5#移动
DISPLAYSURF.fill((255,255,255))#初始化屏幕
DISPLAYSURF.blit(Img,(Imgx,Imgy))#绘制
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
Imgx-=10#移动
pygame.display.update()#更新
fpsClock.tick(FPS)#保持速度