"""
说话泡泡.py,这是李白与杜甫斗诗作品中的Pao类。
"""
import pygame
from pygame.locals import *
class Pao(pygame.sprite.Sprite):
"""说话泡泡类,继承自角色类"""
pygame.init()
fnt = pygame.font.Font("msyh.ttf",18) # 字体对象
hmargin = 10 # 垂直间隙
wmargin = 10 # 水平间隙
bmargin = 30 # 顶下间隙
def __init__(self,string,pos):
"""初始化方法,string:要说的话,pos:坐标
把string转换成surface,贴在泡泡中间
"""
# 字符串的surface,准备贴在image的(wmargin,hmargin)
def main():
"""主要函数"""
size = 480,360
center = size[0]//2,size[1]//2
screen = pygame.display.set_mode(size)
p = Pao('飞流直下三千尺',center)
screen.blit(p.image,p.rect)
pygame.display.update()
if __name__ == "__main__":
main()
如需要查看完整源代码,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

