使用python实现奔跑的线条效果

效果,展示(视频效果展示):

奔跑的线条

from turtle import *

import time

t1=Turtle()

t2=Turtle()

t3=Turtle()

t1.hideturtle()

t2.hideturtle()

t3.hideturtle()

t1.pencolor("red")

t2.pencolor("green")

t3.pencolor("blue")

t1.pensize(5)

t2.pensize(5)

t3.pensize(5)

t1.penup()

t2.penup()

t3.penup()

t1.goto(-50,50)

t2.goto(-40,50)

t3.goto(-30,50)

while 5>2:

for i in range(10):

t1.penup()

t2.penup()

t3.penup()

t1.goto(-50+30*i,50)

t2.goto(-40+30*i,50)

t3.goto(-30+30*i,50)

t1.pendown()

t2.pendown()

t3.pendown()

#t1.forward(10)

#t2.forward(10)

#t3.forward(10)

time.sleep(0.1)

t1.clear()

time.sleep(0.1)

t2.clear()

time.sleep(0.1)

t3.clear()

t1.penup()

t2.penup()

t3.penup()

t1.goto(-50+30*i,50)

t2.goto(-40+30*i,50)

t3.goto(-30+30*i,50)

t1.pendown()

t2.pendown()

t3.pendown()

t1.forward(30)

t2.forward(30)

t3.forward(30)

代码分享:

python 复制代码
from turtle import *
import time
t1=Turtle()
t2=Turtle()
t3=Turtle()
t1.hideturtle()
t2.hideturtle()
t3.hideturtle()
t1.pencolor("red")
t2.pencolor("green")
t3.pencolor("blue")
t1.pensize(5)
t2.pensize(5)
t3.pensize(5)
t1.penup()
t2.penup()
t3.penup()
t1.goto(-50,50)
t2.goto(-40,50)
t3.goto(-30,50)
while 5>2:
    for i in range(10):
        t1.penup()
        t2.penup()
        t3.penup()
        t1.goto(-50+30*i,50)
        t2.goto(-40+30*i,50)
        t3.goto(-30+30*i,50)
        t1.pendown()
        t2.pendown()
        t3.pendown()
        #t1.forward(10)
        #t2.forward(10)
        #t3.forward(10)
        time.sleep(0.1)
        t1.clear()
        time.sleep(0.1)
        t2.clear()
        time.sleep(0.1)
        t3.clear()
        t1.penup()
        t2.penup()
        t3.penup()
        t1.goto(-50+30*i,50)
        t2.goto(-40+30*i,50)
        t3.goto(-30+30*i,50)
        t1.pendown()
        t2.pendown()
        t3.pendown()
        t1.forward(30)    
        t2.forward(30)   
        t3.forward(30)
    
相关推荐
老胖闲聊2 小时前
Python Copilot【代码辅助工具】 简介
开发语言·python·copilot
Blossom.1182 小时前
使用Python和Scikit-Learn实现机器学习模型调优
开发语言·人工智能·python·深度学习·目标检测·机器学习·scikit-learn
曹勖之3 小时前
基于ROS2,撰写python脚本,根据给定的舵-桨动力学模型实现动力学更新
开发语言·python·机器人·ros2
ai大师4 小时前
(附代码及图示)Multi-Query 多查询策略详解
python·langchain·中转api·apikey·中转apikey·免费apikey·claude4
小小爬虾5 小时前
关于datetime获取时间的问题
python
蓝婷儿6 小时前
6个月Python学习计划 Day 16 - 面向对象编程(OOP)基础
开发语言·python·学习
chao_7896 小时前
链表题解——两两交换链表中的节点【LeetCode】
数据结构·python·leetcode·链表
大霞上仙7 小时前
nonlocal 与global关键字
开发语言·python
Mark_Aussie7 小时前
Flask-SQLAlchemy使用小结
python·flask