我知道如何在pygame中显示文本,但是我真正需要的是能够在pygame窗口已经运行时编写文本。
这是我的pygame窗口代码:import pygame
def highscore():
pygame.font.init()
background_colour = (255,255,255)
(width, height) = (600, 600)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Tutorial 1')
screen.fill(background_colour)
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
highscore()
http://www.daniweb.com/software-development/python/code/244474/pygame-text-python
这是一个示例的链接...我想寻找的代码就是这个...
# pick a font you have and set its size
myfont = pg.font.SysFont("Comic Sans MS", 30)
# apply it to text on a label
label = myfont.render("Python and Pygame are Fun!", 1, yellow)
# put the label object on the screen at point x=100, y=100
screen.blit(label, (100, 100))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句