用户:Lili园查看:0 回复:0 评论:0 创建时间:2021-05-24T13:10:45
【作品展示】

【作品介绍】
【作品源代码】
#开始进入Python的世界
import jieba
import wordcloud
import imageio
import pygame
import sys
mk1=imageio.imread('欢欢p.png')
mk2=imageio.imread('喜喜p.png')
w1 = wordcloud.WordCloud(mask=mk1,background_color="white",font_path='simkai.ttf')
w2 = wordcloud.WordCloud(mask=mk2,background_color="white",font_path='simhei.ttf')
txt = open ("欢欢.txt",'r',encoding='utf-8').read()
txt=jieba.lcut(txt)
txt=' '.join(txt)
#w=wordcloud.WordCloud()
w1.generate(txt)
w2.generate(txt)
w1.to_file('hhc.png')
w2.to_file('xxc.png')
'''*******第二部分创建游戏窗口****'''
size = width,height = 800,600
screen=pygame.display.set_mode(size)
pygame.display.set_caption('欢欢喜喜介绍函')
hh = pygame.image.load('欢欢p.png')
xx = pygame.image.load('喜喜p.png')
hhc = pygame.image.load('hhc.png')
xxc = pygame.image.load('xxc.png')
x1=0
y1=200
x2=600
y2=170
y3= 700
y4 = 700
x5 = 800
pygame.init()
font1 = pygame.font.SysFont(None,40)
font2 = pygame.font.SysFont("simhei",50)
font3 = pygame.font.SysFont("simhei",30)
font4 = pygame.font.SysFont("simhei",30)
font5 = pygame.font.SysFont("simhei",30)
font6 = pygame.font.SysFont("simhei",30)
w1 = font1.render('Gvangisih Bouxcuengh Swcigih 1958',1,'orange')
w2 = font2.render('广西壮族自治区',1,'orange')
w3 = font3.render('欢欢',1,'purple')
w4 = font4.render('喜喜',1,'purple')
w5 = font5.render('想要更详细了解我们吗?点我吧',1,'red')
w6 = font6.render('广西欢迎您!',1,'purple')
#mouse_x, mouse_y = pygame.mouse.get_pos()
num=0
pygame.mixer.init()
pygame.mixer.music.set_volume(0.2)
pygame.mixer.music.load('民歌.mp3')
pygame.mixer.music.play()
while True:
mouse_x, mouse_y = pygame.mouse.get_pos()
#num=0
for event in pygame.event.get():
#print(mouse_x)
if event.type==pygame.QUIT:
sys.exit()
elif event.type==pygame.MOUSEBUTTONDOWN:
if event.button ==1:
if mouse_x > 200 and mouse_x <570 and mouse_y > 170 and mouse_y <450:
num = num+1
num=num%2
#print(num)
if num ==0:
screen.fill ('white')
screen.blit(hh,(x1,y1))
screen.blit(xx,(x2,y2))
#print(111)
x1=x1+2
x2=x2-2
y2=y2+0.4
if x1>200:
x1=200
if x2<400:
x2=400
y2=210
screen.blit(w1,(100,100))
screen.blit(w2,(200,40))
screen.blit(w3,(250,y3))
screen.blit(w4,(479,y4))
screen.blit(w5,(x5,150))
y3=y3-1
y4=y4-1
if y3<500:
y3=500
if y4< 500:
y4=500
x5=x5-3
if x5<130:
x5=130
if num==1:
screen.fill('white')
screen.blit(hhc,(x1,y1))
screen.blit(xxc,(x2,y2))
screen.blit(w1,(100,100))
screen.blit(w2,(200,40))
screen.blit(w3,(250,y3))
screen.blit(w4,(479,y4))
screen.blit(w6,(250,140))
pygame.display.update()
pygame.time.delay(15)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn