|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
在pygame中显示文字,按照小甲鱼的视频调用了font.Font方法,但报错如下
Traceback (most recent call last):
File "E:/好好学习/python/code/p80_2.py", line 15, in <module>
font1 = pygame.font.Font(None,20)
OSError: unable to read font file 'E:\软件\python\lib\site-packages\pygame\freesansbold.ttf'
该如何解决,请各位帮忙看看~跪谢
源代码如下,就是小甲鱼的代码:
import pygame
import sys
pygame.init()
size = width,height = 600,400
bg = (0,0,0)
screen = pygame.display.set_mode(size)
pygame.display.set_caption('事件event')
font1 = pygame.font.Font(None,20)
line_height = font1.get_linesize()
position = 0
screen.fill(bg)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.bilt(font1.render(str(event),True,(0,255,0)),(0,position))
position += line_height
if position>height:
position = 0
screen.fill(bg)
pygame.display.flip() |
|