Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pygame闪烁屏幕修复程序_Python_Pygame - Fatal编程技术网

Python pygame闪烁屏幕修复程序

Python pygame闪烁屏幕修复程序,python,pygame,Python,Pygame,我显示记分板的代码总是闪烁,因为我将背景设置为白色。但我想让这一切停止。那么,有没有一种方法可以让pygame在不更新显示的情况下完成所有这些绘图和填充,并且当绘图完成时,它会显示新的结果,这样我就不必看到每一步,从而不必闪烁 def score(): while ScoreTrue: pygame.event.get() window.fill(white) display_score= (display_height/ 1.2)

我显示记分板的代码总是闪烁,因为我将背景设置为白色。但我想让这一切停止。那么,有没有一种方法可以让pygame在不更新显示的情况下完成所有这些绘图和填充,并且当绘图完成时,它会显示新的结果,这样我就不必看到每一步,从而不必闪烁

def score():
    while ScoreTrue:
        pygame.event.get()
        window.fill(white)
        display_score= (display_height/ 1.2)
        message_display("Scoreboard", 2, 5)
        message_meduim("5th place: " + ", ".join( repr(e) for e in Scoreboard[0] ), 3, display_score)
        message_meduim("4th place:" + ", ".join( repr(e) for e in Scoreboard[1]), 3, display_score - 100)
        message_meduim("3rd place:" + ", ".join( repr(e) for e in Scoreboard[2]), 3, display_score - 200)
        message_meduim("2nd place:" + ", ".join( repr(e) for e in Scoreboard[3]), 3, display_score - 300)
        message_meduim("1st place:" + ", ".join( repr(e) for e in Scoreboard[4]), 3, display_score - 400)
        Button("Play again", display_width/1.2,display_height/1.6, display_width/8, display_height/9, red, red_light, "play")

如果您有一个显示窗口的while循环(我假设您有),那么您可能在循环中调用
pygame.display.flip()
,或者调用
pygame.display.update()
。因此,您也不必在score函数中调用
pygame.display.update()
。删除
score
函数中的
pygame.display.update()
,只需在while循环中调用
score
函数。

如果有一个while循环显示窗口(我假设你有),那么你可能在循环中调用
pygame.display.flip()
,或者
pygame.display.update()
。因此,您也不必在score函数中调用
pygame.display.update()
。删除
score
函数中的
pygame.display.update()
,只需调用while循环中的
score
函数即可