mport pygame
#开始游戏代码的编写
#初始化程序窗口
pygame.mixer.init()
#窗口
screen = pygame.display.set_mode((400,600))
#窗口名
pygame.display.set_caption("飞机大战")
#加载背景图
bg_img = pygame.image.load("resource/bg.png")
#加载飞机
player = pygame.image.load("resource/player.png")
#设置背景图初始的位置
bg_img_x = 0
bg_img_y = 0
#设置飞机的初始位置
player_x = 0
player_y = 0
#设置飞机的初始速度
step_y = 0
step_x = 0
running = True
while running
bg_img_x -= -1
if player_y > 536
player_x = 536
if player_y < 0
player_y = 0
if player_x > 336
player_x = 336
if player_x < 0
player_x = 0
player_x += step_x
player_y += step_y
screen.blit(bg_img,(bg_img_x,bg_img_y))
screen.blit(player,(player_x,player_y)
if bg_img_x -400 < -800
bg_img_x = 0
evetList = pygame.event.get()
for event in evetList:
running = False
print("点击窗口关闭")
运行的话他出现
ile "D:/py/fj.py", line 24
while (running)
^
SyntaxError: invalid syntax