わかりましたので、私は学校のためにこのプロジェクトに取り組んでいます。スペースインベーダー系のゲームを作ろうと思っています。船を動かして発砲するように仕上げました。ここに問題があります。マルチファイアしようとすると、以前に発射された弾丸が消去され、まったく良いサイトではない新しい弾丸が発射されます。実際に複数のショットを発射するにはどうすればよいですか?
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)