用Python和Pygame写游戏-从入门到精通(4)字体

来源:互联网 发布:淘宝客服接待用语 编辑:程序博客网 时间:2024/05/29 18:16

1、字体


import pygamefrom pygame.locals import *from sys import exitclose = Falsepygame.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 = 0y = (480 - text_surface.get_height())/2background = 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()


阅读全文
0 0
原创粉丝点击