博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用pygame绘制文字
阅读量:3959 次
发布时间:2019-05-24

本文共 563 字,大约阅读时间需要 1 分钟。

一、使用文字需要导入一个方法 freetype

具体方法
pygame.freetype.Font(“C:\Windows\Fonts\方正粗黑宋简体.ttf”,24)
前者表示字体类型,后者表示字体大小
字体类型在电脑的c盘Windows >>fonts文件下

import pygame,sysimport pygame.freetypepygame.init()pos=[150,150]GOLD=255,251,0BLACK=0,0,0screen=pygame.display.set_mode((600,400))pygame.display.set_caption("绘制文字")f1=pygame.freetype.Font("C:\Windows\Fonts\方正粗黑宋简体.ttf",24)f1rect=f1.render_to(screen,pos,"世界和平,承蒙关照",fgcolor=GOLD,bgcolor=BLACK,)while True:    for event in pygame.event.get():        if event.type == pygame.QUIT:            sys.exit()        pygame.display.update()

转载地址:http://otmzi.baihongyu.com/

你可能感兴趣的文章
drbd
查看>>
网络 IP
查看>>
网络路由
查看>>
网络 tcp 性能 可靠
查看>>
网络 https 握手
查看>>
去掉调试信息
查看>>
lsof 使用
查看>>
golang获取本机地址
查看>>
date 使用
查看>>
ipcalc
查看>>
网络 linux 禁止 ping
查看>>
ELF 格式详解
查看>>
chromium 使用
查看>>
linux 检测虚拟机类型
查看>>
go - 运行时:内存不足
查看>>
top 使用
查看>>
Linux Netlink通信机制详解
查看>>
rsync 远程同步
查看>>
nano使用
查看>>
c函数
查看>>