Reputation: 73
I want to add a color to the background of a basic game but I keep getting the invalid color argument
I've tried removing bg_color
entirely but still gives the same error
def run_game():
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("First Game")
ship = Ship(screen)
bg_color = (230, 230, 230)
while True:
check_events(ship)
ship.update()
screen.fill(ai_settings, bg_color)
ship.blitme()
pygame.display.flip()
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
screen.fill(ai_settings.bg_color)
ship.blitme()
pygame.display.flip()
run_game()
File "C:/Users/Areeb Irfan/.PyCharmCE2018.3/config/scratches/AlienGame.py", line 40, in <module>
run_game()
File "C:/Users/Areeb Irfan/.PyCharmCE2018.3/config/scratches/AlienGame.py", line 31, in run_game
screen.fill(ai_settings, bg_color)
TypeError: invalid color argument
Upvotes: 1
Views: 786
Reputation: 6436
fill
just takes one argument. And bg_color
is not an attribute of ai_settings
. You need to change your line to:
screen.fill(bg_color)
Upvotes: 2