python海龟画图制作的漂亮的下雪场景动画效果冰雪奇缘

"""本程序模拟雪花下雪效果,有一个漂亮的序幕,窗口会越放越大..."""

from turtle import *
from snow import *
from time import sleep
  

def supersleep(number,screen):
    """等待再刷新屏幕,防止屏幕假死"""
    for i in range(100):
        sleep(number/100)
        screen.update()
        
def make_snow_shape(length):
    """定义米字型的形状,然后注册到形状列表"""
    turtle = Turtle(visible=False )
    turtle.begin_poly()
    for i in range(8):
        turtle.fd(length)
        turtle.bk(length)
        turtle.right(45)
    turtle.end_poly()
    p = turtle.get_poly()
    turtle.screen.addshape("snow",p)
    turtle.clear()


#background_png = [ "title/frozen" + (3-len(str(i)))*"0" + str(i) + ".png" for i in range(1,43)] #背景帧图
background_png = [ f"title/frozen{i:03d}.png" for i in range(1,43)]
background = "800x445.png"           # 背景图    
width,height = 640,285               # 屏幕宽度和高度

screen = Screen()
screen.title("冰雪奇缘_雪花飞舞_by_www.lixingqiu.com")
screen.delay(0)
make_snow_shape(5)                   # 定义雪花形状
screen.setup(width,height)
screen.bgcolor("black")

You must log in to read the rest of this article. Please log in or register as a user.