人家用海龟画图进行绘画,我用海龟画图制作了一个相声。以下是部分代码预览:
"""这是一个Python动画,显示的是两个人讲相声,相声是我自己编的。""" import os from surtle import * from face_and_functions import * def match_condition(line=""): """检测一行中是否包括两个冒号,本函数用下列一行也可以定义: match_condition = lambda line="":list(line).count(":") == 2 """ s = line.split(":") if len(s) == 3 : return True else: return False def talk_end(): """相声结束后显示的文字信息。""" screen.bgpic("images/背景.png") t = Turtle(visible=False) t.penup() t.sety(-50) t.color("cyan") info = "大数据,指互联网不断产生\n的海量数据集合,需要新处理\n模式才能让它转换为真正有\n价值的信息资产。" def load(cross_talk_file): """加载装有相声文字的文本文件。""" words = [] f = open(cross_talk_file) return words def cross_talk(cross_talk_file): """说相声函数,轮流从列表中显示文字""" boy = Surtle() boy.goto(-150,-60) girl = Surtle() girl.setheading(180) girl.goto(150,10) def wait_fall_end(): if face.shakecounter>0: screen.ontimer(wait_fall_end,1000) else: face.hideturtle() screen.bgpic("images/篮球场背景.png") if __name__ =="__main__": project_name = "相声《大数据》_作者:李兴球" success_sound = "audios/胜利鼓掌吹.wav" aa_sound = "audios/乌鸦叫.wav" xiao_sound = "audios/大笑.wav" silent_sound = "audios/silent.wav" sound_names = ['success_sound','aa_sound','xiao_sound','silent_sound'] sound_files = [success_sound,aa_sound,xiao_sound,silent_sound] sounddict= init_sound(sound_names,sound_files) playsound(sounddict["success_sound"]) # 笑声来了... screen = init_screen(project_name,480,360,"images/背景.png",["images/笑掉牙.gif"]) face = Face(shape = "images/笑掉牙.gif") wait_fall_end() screen.mainloop()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)