python game练习4

来源:互联网 发布:网络第一神书悟空传 编辑:程序博客网 时间:2024/05/23 17:04
#! /usr/bin/env python2.7# -*- coding:utf-8 -*-#File:PG4_1.py#Date:2013-7-5#Author:wangyuimport pygamefrom pygame.locals import *from sys import exitpygame.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=0y=(480-text_surface.get_height())/2background=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()

这个部分主要是字体的支持,在一个游戏中离开了字体,还怎么活?

那个你好就是文件中的字体,

感谢原作者的努力
原创粉丝点击