好的,所以我正在为学校做这个项目。我应该做一个太空侵略者类型的游戏。我已经完成了我的船移动和射击。现在问题来了,当我尝试多发时,它会擦除之前发射的子弹并发射新的子弹,这根本不是一个好位置。我怎样才能让它真正发射多发子弹?
while (running == 1):
screen.fill(white)
for event in pygame.event.get():
if (event.type == pygame.QUIT):
running = 0
elif (event.type == pygame.KEYDOWN):
if (event.key == pygame.K_d):
dir = "R"
move = True
elif (event.key == pygame.K_a):
dir = "L"
move = True
elif (event.key == pygame.K_s):
dir = "D"
move = True
elif (event.key == pygame.K_w):
dir = "U"
move = True
elif (event.key == pygame.K_ESCAPE):
sys.exit(0)
elif (event.key == pygame.K_SPACE):
shot=True
xbul=xgun + 18
ybul=ygun
#if key[K_SPACE]:
#shot = True
if (event.type == pygame.KEYUP):
move = False
#OBJECT'S MOVEMENTS
if ((dir == "R" and xgun<460) and (move == True)):
xgun = xgun + 5
pygame.event.wait
elif ((dir == "L" and xgun>0) and (move == True)):
xgun = xgun - 5
pygame.event.wait
elif ((dir == "D" and ygun<660) and (move == True)):
ygun = ygun + 5
pygame.event.wait
elif ((dir == "U" and ygun>0) and (move == True)):
ygun = ygun - 5
screen.blit(gun, (xgun,ygun))
#PROJECTILE MOTION
#key = pygame.key.get_pressed()
if shot == True:
ybul = ybul - 10
screen.blit(bullet, (xbul, ybul))
if xbul>640:
shot=False
pygame.display.flip()
time.sleep(0.012)