Prueba con esto:
Código Python:
Ver originalimport pygame, os
class Text:
def __init__(self, FontName = None, FontSize = 30):
pygame.font.init()
self.font = pygame.font.Font(FontName, FontSize)
self.size = FontSize
def render(self, surface, text, color, pos):
text = unicode(text, "UTF-8")
x, y = pos
for i in text.split("\r"):
surface.blit(self.font.render(i, 1, color), (x, y))
y += self.size
def load_image(path, colorkey=False):
_image = pygame.image.load(path)
if colorkey:
if colorkey == -1:
colorkey = _image.get_at((0, 0))
_image.set_colorkey(colorkey)
image.set_colorkey(colorkey)
_image = _image.convert()
else:
_image = _image.convert_alpha()
return _image
pygame.init()
white = (255, 255, 255)
size = width, height = 640, 480
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Pygame Hello Word!")
color = (0, 0, 0)
text = Text()
background = load_image(os.path.join("data", "imagen1.jpg"))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
exit()
screen.blit(background, background.get_rect())
text.render(screen, "Hello Word!", white, (0, 0))
pygame.display.flip()