#! /usr/bin/env python2.7
# -*- coding:utf-8 -*-
#File:PG4_1.py
#Date:2013-7-5
#Author:wangyu
import pygame
from pygame.locals import *
from sys import exit
pygame.init()
screen =pygame.display.set_mode((640,480),0,32)
font =pygame.font.SysFont("宋体",40)
text_surface=font.render(u"你好",True,(0,0,255))
x=0
y=(480-text_surface.get_height())/2
background=pygame.image.load("8wxpython.jpg").convert()
while True:
for event in pygame.event.get():
if event.type==QUIT:
exit()
screen.blit(background,(0,0))
x -=2 #如果文字滚动过快,改改这个数字
if x<640-text_surface.get_width():
x=640-text_surface.get_width()
screen.blit(text_surface,(x,y))
pygame.display.update()
这个部分主要是字体的支持,在一个游戏中离开了字体,还怎么活?
那个你好就是文件中的字体,
感谢原作者的努力