Blit 错误的无效目标位置

Invalid destination position for blit error

我收到这个错误。这是完整的回溯。

Traceback (most recent call last):
File "C:/Users/hobin/PycharmProjects/codeitPython/Snake_game.py", line 103, in <module>
snakegame()
File "C:/Users/hobin/PycharmProjects/codeitPython/Snake_game.py", line 52, in snakegame
dis.blit(value, round(display_width / 3), round(display_height / 5))
TypeError: invalid destination position for blit

这是与错误相关的代码

while not game_over:
    while game_end == True:
        #For displaying the score
        score = Length_of_snake -1
        score_font = pygame.font.SysFont("comicsansms", 35)
        value = score_font.render("Your Score: " + str(score), True, greencolor)
        dis.blit(value, round(display_width / 3), round(display_height / 5))
        pygame.display.update()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_over = True # The game window is still open
                game_end = False # game has been ended

我没有任何线索...我该怎么办??

pygame.Surfac.blit的第二个参数(dest)是一对坐标。包含 2 个组件的元组或包含 2 个元素的列表:

dis.blit(value, round(display_width / 3), round(display_height / 5))

dis.blit(value, ( round(display_width / 3), round(display_height / 5) ) )

为了完整起见,必须提到参数也可以是矩形。具有 4 个组件(左、上、宽、高)的元组。