12月1日课堂笔记及作业

课前回顾
eg:申明变量age,为age赋值自己的年龄,并且打印出来
age = 18
print(age)

计算机英语
font 字体 render 表达

本周知识点
pygame.font.SysFont() 方法
-设置游戏中的字体和字体大小的方法
-pygame 工具箱
-font 工具
-SysFont() 需要怎么使用工具

课堂练习
while True:
#创建变量tf设置文字的字体和大小
tf = pygame.font.SysFont("微软雅黑",40)
st = pygame.font.SysFont("宋体",50)
hello = tf.render('hello',False,(255,0,0))
#屏幕的传输方法
screen.blit(hello,(200,200))
# 更新屏幕内容
pygame.display.update()
#处理关闭游戏
handleEvent()

while True:
screen.blit(bg, (0, 0))
#设置文字的字体和大小
tf = pygame.font.SysFont('幼圆',50)
#在背景中添加生命值
life = tf.render("LIFE:99",True,(255,0,0))
screen.blit(life,(350,5))
#在背景中添加分数
score = tf.render("SCORE:100000",False,(0,255,0))
screen.blit(score,(10,5))
# 更新屏幕内容
pygame.display.update()
#处理关闭游戏
handleEvent()

作业:设置红色的hello和绿色的python传输到屏幕上.

while True:
#绑定文字设置字体及大小
tf = pygame.font.SysFont("微软雅黑",40)

#绑定hello变量
hello = tf.render("hello",False,(255,0,0))

#传输hello到屏幕
screen.blit(hello,(300,200))
#绑定python 变量
python =tf.render("python",True,(0,255,0))
#传输python 到屏幕
screen.blit(python,(300,300))
# 更新屏幕内容
pygame.display.update()
#处理关闭游戏
handleEvent()

猜你喜欢

转载自www.cnblogs.com/shengling/p/10050220.html