用Python和Pygame写游戏-从入门到精通(4)字体
2017-08-30 13:47
671 查看
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()
相关文章推荐
- 用Python和Pygame写游戏-从入门到精通(4)
- 用Python和Pygame写游戏-从入门到精通(1)
- 用Python和Pygame写游戏-从入门到精通(19)
- 用Python和Pygame写游戏-从入门到精通(8)
- 用Python和Pygame写游戏-从入门到精通(15)
- 用Python和Pygame写游戏-从入门到精通(21)
- 用Python和Pygame写游戏-从入门到精通(5)像素、色彩、颜色
- 用Python和Pygame写游戏-从入门到精通(1)
- 用Python和Pygame写游戏-从入门到精通(14)
- 用Python和Pygame写游戏-从入门到精通(17)
- 用Python和Pygame写游戏-从入门到精通(13)简单的AI游戏
- 用Python和Pygame写游戏-从入门到精通(2)
- 用Python和Pygame写游戏-从入门到精通(18)
- 用Python和Pygame写游戏-从入门到精通(1)
- 用Python和Pygame写游戏-从入门到精通(实战一:涂鸦画板)
- 用Python和Pygame写游戏-从入门到精通(2)
- 用Python和Pygame写游戏-从入门到精通(15)
- 用Python和Pygame写游戏-从入门到精通(1)
- 用Python和Pygame写游戏-从入门到精通(8)
- 用Python和Pygame写游戏-从入门到精通(19)