turtle可移动向后滚动背景_turtle scroll background


本程序让海龟变身隧道图,让它们不断地向后移动,从而形成滚动效果背景。
下面是部分代码预览:

"""
  可移动向后滚动背景,。
"""
from turtle import *

screen = Screen()
screen.setup(480,360)
screen.title("向后滚动的背景")
screen.bgcolor("blue")
screen.delay(0)
screen.bgpic("隧道.png")

backgrounds =["隧道1.gif","隧道2.gif","隧道3.gif"]
[screen.addshape(bg) for bg in backgrounds]
    
costuems = ['造型1.gif','造型2.gif']
[screen.addshape(c) for c in costuems]
    
bg_index = 0                # 全局背景索引号
currentbg = backgrounds[bg_index]
bg1 = Turtle(shape=currentbg)
bg1.speed(0)
bg1.penup()
 
bg2 = bg1.clone()
alt = 1
 
screen.mainloop()

下载完整源代码与素材,请

成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

关于李兴球

李兴球的博客是Python创意编程原创博客
此条目发表在python, turtle分类目录。将固定链接加入收藏夹。