turtle制作的中秋节的夜空云彩和仙女慢慢出现动画


python中秋节的夜空云彩和仙女慢慢出现动画

"""中秋节的夜空云彩和仙女慢慢出现,这是用海龟画图像块制作的一个小动画."""

from turtle import Turtle,Screen

def slide_cloud(t):     
    t.setx(t.xcor() + 1)
    if t.xcor() > t.screen.window_width() // 2 + 300:
        t.hideturtle()
        t.setx(-100 - t.screen.window_width() // 2)
        t.showturtle()

    if hasattr(t,'name') :                         # 如果有这个属性,说明它是诗
        if t.xcor() ==0 :return
    
    t.screen.ontimer(lambda :slide_cloud(t),100)

def slide_fairy(t):     
    t.setx(t.xcor() - 1)
    if t.xcor() < -t.screen.window_width() // 2 - 300:
        t.hideturtle()
        return
    
    t.screen.ontimer(lambda :slide_fairy(t),100)
    
fairy = "仙女.gif"
cloud1 = "云1.gif"
cloud2 = "云2.gif"
cloud3 = "云3.gif"
poem  = "明月几时有x.gif"
images = [fairy,cloud1,cloud2,cloud3,poem]
width ,height = 800,600

screen = Screen()
screen.setup(width,height)
screen.title("中秋节的夜空云彩和仙女慢慢出现 by lixingqiu")
screen.bgcolor("black")
screen.bgpic('中秋夜空.png')
screen.delay(0)
[screen.addshape(image) for image in images]

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