import pygame, sys
from pygame.locals import *
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = ( 255, 0, 0)
pygame.init()
size = (700, 500)
screen = pygame.display.set_mode(size)
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('P.Earth')
while 1: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.display.update()
import time
direction = ''
print('Welcome to Earth')
pygame.draw.circ(screen, RED, [55,500,10,5], 0)
time.sleep(1)
print('Earth was a very prosperous planet. Filled with life and culture.')
time.sleep(2)
这只是其中的一部分。它不会显示在pygame屏幕上。 (如果你想知道我最后使用pygame.quit()
)我只是想让它起作用。如果你能让你的答案更简单,那就太棒了,因为我还是个初学者。我该如何显示文字?任何帮助都可以。感谢。
答案 0 :(得分:0)
您正在寻找使用pygame font
模块。
这是渲染然后在屏幕上定位字体的示例。 ()
import pygame.font
font = pygame.font.Font(None, 36) # None can be a font file instead
text = font.render("Welcome to Earth", 1, (0, 0, 0))
# Determine the location that should be allocated for the text
text_box = text.get_rect(centerx=DISPLAYSURF.get_width()/2)
# Draw the text onto the background
background.blit(text, text_box)