我是 Python 和 Pygame 的新手,我开始制作一个简单的游戏,在飞越敌人的玩家下方射击,以测试我学到的东西。当它运行时,我只是收到错误消息,说它不需要字符串。如下:
bgi="bg.png" #BACKGROUND IMAGE
pi="man.png" #PLAYER IMAGE
proji="proj.png" #PROJECTILE IMAGE
import pygame, sys #Import
from pygame.locals import * #Import
pygame.init() #Initialize
screen=pygame.display.set_mode((1000,600),0,32) #Display
background=pygame.image.load(bgi).convert() #Background
player=pygame.image.load(pi).convert_alpha() #Player
proji2=pygame.transform.rotate(proji, 180) #Rotate
x=0 #variables
y=0
mx=0
mv=0
projiy=0
player.pos=(x,y)
while True: #Loop
for event in pygame.event.get():
if event.type==QUIT: #X Clicked
pygame.quit()
sys.exit()
if event.type==KEYDOWN: #Key Press
if event.key==K_a:
mx=-1
elif event.key==K_d:
mx=+1
elif event.key==K_s:
screen.blit(proji2, player.pos)
my=+1
if event.type==KEYUP: #Key Release
if event.key==K_a:
mx=0
elif event.key==K_d:
mx=0
elif event.key==K_s:
my=0
x+=mx
projiy+=mv
screen.blit(background, (0,0)) #Display
screen.blit(player, (x,y))
pygame.display.update() #Update
谁能帮我找出错误并向我解释为什么他们错了?谢谢!