question = "Is this a question?"
# Render the text:
font = pygame.font.SysFont("Arial", 20)
text_surface = font.render(question, true, (0,0,0))
# Blit the text to the screen
text_rect = text_surface.get_rect()
text_rect.center = (100,100)
screen.blit(text_surface, text_rect.topleft)
从文本文件加载问题听起来不错。使用pygame,您可以在屏幕上的任何位置定位文本,这是一个两步过程:
这就把问题拉到了想要的位置。你知道吗
如果要处理多行问题,可以在文件中使用一个特殊字符来指示换行符(例如管道|),也可以制作一个算法来自动找出换行符的放置位置。接下来渲染并逐行blit,向y坐标添加一些像素。你知道吗
相关问题 更多 >
编程相关推荐