|
TypeError: add() argument after * must be an iterable, not Settings
我的代码是这样的
import sys
import pygame
from bullet import Bullet
def check_keydown_events(event,ai_settings,screen,plane,bullets):
if event.key==pygame.K_RIGHT:
plane.moving_right=True
elif event.key==pygame.K_LEFT:
plane.moving_left=True
elif event.key==pygame.K_UP:
plane.moving_up=True
elif event.key==pygame.K_DOWN:
plane.moving_down=True
elif event.key==pygame.K_SPACE:
new_bullet=Bullet(ai_settings,screen,plane)
bullets.add(new_bullet)
def check_keyup_events(event,plane):
if event.key==pygame.K_RIGHT:
plane.moving_right=False
elif event.key==pygame.K_LEFT:
plane.moving_left=False
elif event.key==pygame.K_UP:
plane.moving_up=False
elif event.key==pygame.K_DOWN:
plane.moving_down=False
def check_events(ai_settings,screen,plane,bullets):
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
elif event.type==pygame.KEYDOWN:
check_keydown_events(event,ai_settings,screen,plane,bullets)
elif event.type==pygame.KEYUP:
check_keyup_events(event,plane)
def update_screen(ai_settings,screen,plane,bullets):
screen.fill(ai_settings.bg_color)
for bullet in bullets.sprites():
bullet.draw_bullet()
plane.blitme()
pygame.display.flip()
|
|