Python Turtle召唤童年:《哆啦A梦的奇妙世界》
- 🐸 前言 🐸
- 🐋 效果图 🐋
- 🐉 代码 🐉
🐸 前言 🐸
欢迎来到 《哆啦A梦的奇妙世界》,在这个博客里,我们将与来自未来的蓝色猫型机器人——哆啦A梦,一起踏上穿越时空的冒险旅程。自从1970年首次亮相,哆啦A梦便成为了无数人心中永恒的朋友,他不仅是大雄的救星,也是我们的心灵伙伴。
在这个博客里,我们不仅将回顾《哆啦A梦》的经典形象,探索哆啦A梦背后的科学幻想与温情友情,还会与各位一起讨论如何从这个充满无限可能的未来世界中汲取智慧与启发。无论是哆啦A梦的神奇口袋,还是他与小伙伴们的温暖互动,都传递着关爱、勇气与希望。
🐋 效果图 🐋
🐉 代码 🐉
from turtle import*
import time
# 设置抬笔跳跃
def my_goto(x, y):
penup()
goto(x, y)
pendown()
# 绘制项圈
def collar():
color("red")
pencolor("black")
begin_fill()
my_goto(-100, 0)
lt(10)
circle(-800, 20)
rt(70)
fd(10)
goto(-100, -10)
goto(-100, 0)
end_fill()
# 绘制大脸
def face():
color("sky blue")
pencolor("black")
begin_fill()
lt(46)
circle(251,-293)
lt(10)
circle(200,273)
end_fill()
# 绘制眼睛
def eyes():
# 绘制左眼
my_goto(-45,338)
color("white")
begin_fill()
pencolor("black")
tracer(False)
a = 3
rt(45)
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
# 绘制左眼球
color("black")
begin_fill()
pencolor("black")
my_goto(-5, 320)
circle(15)
end_fill()
color("white")
begin_fill()
my_goto(10, 318)
circle(5)
end_fill()
# 绘制右眼
my_goto(45,338)
color("white")
begin_fill()
pencolor("black")
tracer(False)
a = 3
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
# 绘制右黑眼球
color("black")
begin_fill()
pencolor("black")
my_goto(50,320)
circle(15)
end_fill()
color("white")
begin_fill()
my_goto(54, 318)
circle(5)
end_fill()
# 绘制鼻子
def nose():
pensize(3)
color("red")
begin_fill()
pencolor("black")
my_goto(4,272)
circle(35)
end_fill()
# 绘制鼻尖
color("white")
begin_fill()
my_goto(33, 290)
circle(5)
end_fill()
# 绘制嘴巴
def mouse():
pencolor("black")
my_goto(38,202)
goto(38,50)
my_goto(-110,160)
lt(15)
circle(150,150)
# 绘制胡子
def beard():
pencolor("black")
pensize(4)
# 绘制左边的胡子
my_goto(-120,200)
goto(-20,180)
my_goto(-120, 170)
goto(-20,160)
my_goto(-120, 130)
goto(-20,140)
# 绘制右边的胡子
my_goto(196,200)
goto(96,180)
my_goto(196, 170)
goto(96,160)
my_goto(196, 130)
goto(96,140)
# 绘制猫身
def body():
color("sky blue")
begin_fill()
pencolor("black")
# 左半边的身子
my_goto(-100, -10)
rt(35)
fd(-180)
circle(-50,-180)
fd(-80)
lt(50)
fd(-60)
fd(190)
rt(30)
fd(60)
lt(115)
fd(80)
lt(10)
fd(65)
#机器猫的裤裆
lt(90)
circle(-35,190)
lt(90)
fd(65)
rt(-10)
fd(80)
# 右半边的身子
lt(115)
fd(60)
rt(35)
fd(190)
fd(-60)
rt(60)
fd(180)
circle(50,180)
goto(185,-10)
goto(-100, -10)
end_fill()
# 绘制猫肚子
def belly():
color("white")
pencolor("black")
begin_fill()
my_goto(-80,-10)
seth(0)
lt(80)
circle(-120, -200)
end_fill()
my_goto(-10,-70)
seth(0)
lt(80)
circle(-50, -200)
goto(-10,-70)
# 绘制铃铛
def bell():
my_goto(38,-10)
seth(180)
color("yellow")
begin_fill()
pencolor("black")
circle(20)
end_fill()
# 绘制双手
def hand():
# 绘制左手
color("white")
begin_fill()
pencolor("black")
my_goto(-230,-125)
circle(60)
end_fill()
# 绘制右手
color("white")
begin_fill()
pencolor("black")
my_goto(380, 50)
circle(60)
end_fill()
# 绘制双脚
def foot():
# 绘制左脚
color("white")
begin_fill()
pencolor("black")
my_goto(-10, -330)
seth(0)
fd(10)
circle(-35, 180)
fd(140)
circle(-35, 180)
# fd(10)
goto(-10,-330)
end_fill()
# 绘制右脚
color("white")
begin_fill()
pencolor("black")
my_goto(220, -330)
seth(0)
fd(10)
circle(-35, 180)
fd(140)
circle(-35, 180)
# fd(10)
goto(220,-330)
end_fill()
# 调用函数
def main():
hideturtle()
speed(2)
pensize(3)
collar()
face()
eyes()
nose()
mouse()
beard()
body()
belly()
bell()
hand()
foot()
exitonclick()
if __name__ == '__main__':
main()
time.sleep(20) #停止20s