Python display text with font & color?

后端 未结 5 1232
醉话见心
醉话见心 2020-12-05 06:16

Is there a way I can display text on a pygame window using python?

I need to display a bunch of live information that updates and would rather not make an image for

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-05 06:50

    I have some code in my game that displays live score. It is in a function for quick access.

    def texts(score):
       font=pygame.font.Font(None,30)
       scoretext=font.render("Score:"+str(score), 1,(255,255,255))
       screen.blit(scoretext, (500, 457))
    

    and I call it using this in my while loop:

    texts(score)
    

提交回复
热议问题