1、字体
import pygame
from pygame.locals import *
from sys import exit
close = False
pygame.init()
screen = pygame.display.set_mode((640, 480), 0, 32)
font = pygame.font.Font("simsun.ttc", 40)
text_surface = font.render(u"你好", True, (0, 0, 255))
x = 0
y = (480 - text_surface.get_height())/2
background = pygame.image.load("sushiplate.jpg").convert()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit
close = True
if close == True:
break
screen.blit(background, (0, 0))
x -= 0.1
if x < -text_surface.get_width():
x = 640 - text_surface.get_width()
screen.blit(text_surface, (x, y))
pygame.display.update()