gpt4 book ai didi

python - 颜色参数无效

转载 作者:行者123 更新时间:2023-12-01 00:43:54 25 4
gpt4 key购买 nike

我想向基本游戏的背景添加颜色,但我不断收到无效的颜色参数

我尝试完全删除 bg_color 但仍然给出相同的错误

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

最佳答案

fill 仅接受一个参数。并且bg_color不是ai_settings的属性。您需要将线路更改为:

screen.fill(bg_color)

关于python - 颜色参数无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57136668/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com