turtle——春夏秋冬,画册超好玩

1.春

#from turtle import *
#from random import *
def a():
    import turtle as t
    import random as r
    t.speed(0)
    t.bgcolor('blue')
    t.pencolor('orange')
    t.pensize(5)
    t.fillcolor('red')
    t.begin_fill()
    t.circle(200)
    t.end_fill()
    t.pu()
    t.goto(-400,-350)
    t.pd()
    t.fillcolor('light green')
    t.begin_fill()
    for i in range(2):
        t.fd(800)
        t.left(90)
        t.fd(400)
        t.left(90)
    t.end_fill()
    for i in range(5):
        x = r.randint(-300,300)
        y = r.randint(-300,0)
        t.pu()
        t.goto(x,y)
        t.pd()
        t.seth(r.randint(60,80))
        t.pensize(5)
        t.pencolor('brown')
        t.fd(100)
        t.pensize(1)
        for i in range(10):
            for j in range(6):
                t.forward(10)
                t.right(360 / 6)
            t.right(360 / 10)
        t.pencolor('brown')
        t.fd(-100)
    for j in range(10):
        x = r.randint(-300, 300)
        y = r.randint(-300, 0)
        t.pu()
        t.goto(x, y)
        t.pd()
        for i in range(5):
            t.seth(r.randint(65,95))
            t.pensize(5)
            t.pencolor('green')
            f = r.randint(50,100)
            t.fd(f)
            t.fd(-f)

2.夏

#from turtle import *
#from random import *
def b():
    import turtle as t
    import random as r
    t.speed(0)
    t.bgcolor('blue')
    t.pencolor('orange')
    t.pensize(5)
    t.fillcolor('red')
    t.begin_fill()
    t.circle(200)
    t.end_fill()
    t.pu()
    t.goto(-400,-350)
    t.pd()
    t.fillcolor('light blue')
    t.begin_fill()
    for i in range(2):
        t.fd(800)
        t.left(90)
        t.fd(400)
        t.left(90)
    t.end_fill()
    for c in range(randint(5,10)):
        t.seth(0)
        x = r.randint(-300, 300)
        y = r.randint(-300, -100)
        t.pu()
        t.goto(x, y)
        t.pd()
        t.pencolor('green')
        t.fillcolor('light green')
        t.begin_fill()
        t.circle(50)
        t.end_fill()
        t.seth(90)
        t.fd(50)
        for i in range(8):
            t.fd(50)
            t.fd(-50)
            t.right(360/8)
    c=['red','pink']
    t.pensize(1)
    for i in range(randint(5,10)):
        t.seth(90)
        t.fillcolor(c[i%2])
        t.begin_fill()
        x=r.randint(-300,300)
        y=r.randint(-300,-50)
        for i in range(6):
            t.pu()
            t.goto(x,y)
            t.pd()
            t.circle(50,90)
            t.left(90)
            t.circle(50,90)
            t.left(90)
            t.right(360/19)
        t.end_fill()
    mainloop()

3.秋

def c():
    import turtle as t
    import random as r
    def fc(cd,cen,cx):
        t.colormode(255)
        t.pencolor(102,51,0)
        if cen >= 0:

            t.speed(0)
            t.pensize(cx)
            t.fd(cd)
            t.left(15)
            c = r.randint(10,100)
            fc(c,cen-1,cx-4)
            t.pencolor('yellow')
            t.fd(10)
            t.circle(2)
            t.bk(10)
            t.right(30)
            c= r.randint(10, 100)
            fc(c, cen - 1, cx-4)
            t.left(15)
            t.bk(cd)

    t.speed(0)
    t.bgcolor('blue')
    t.pencolor('orange')
    t.pensize(5)
    t.fillcolor('red')
    t.begin_fill()
    t.circle(200)
    t.end_fill()
    t.pu()
    t.goto(-400,-350)
    t.pd()
    t.fillcolor('yellow')
    t.begin_fill()
    for i in range(2):
        t.fd(800)
        t.left(90)
        t.fd(400)
        t.left(90)
    t.end_fill()
    t.pu()
    t.goto(0,0)
    t.pd()
    x = 100
    y = -300
    t.pencolor('orange')
    for a in range(10):
        x = 100 + (a * 10)
        for yf in range(10):
            t.pu()
            t.goto(x, y)
            t.pd()
            t.seth(100)
            t.fd(50)
            t.circle(25,120)
            x += 20
        y += 30
    t.pu()
    t.goto(-200,-200)
    t.pd()
    t.seth(90)
    fc(60,4,20)

4.冬

def d():
    import turtle as t
    import random as r

    t.speed(0)
    t.bgcolor('blue')
    t.pencolor('orange')
    t.pensize(5)
    t.fillcolor('red')
    t.begin_fill()
    t.circle(200)
    t.end_fill()
    t.pu()
    t.goto(-400,-350)
    t.pd()
    t.fillcolor('white')
    t.begin_fill()
    for i in range(2):
        t.fd(800)
        t.left(90)
        t.fd(400)
        t.left(90)
    t.end_fill()
    #画房子
    x = -300
    y = -225
    t.pu()
    t.goto(x,y)
    t.pd()
    t.fillcolor('brown')
    t.begin_fill()

    for i in range(4):
        t.fd(200)
        t.left(90)
    t.end_fill()
    t.fillcolor('brown')
    t.begin_fill()
    t.fd(20)
    t.seth(90)
    t.fd(100)
    t.right(90)
    t.fd(50)
    t.right(90)
    t.fd(100)
    t.pu()
    t.goto(x+200,y+200)
    t.pd()
    t.seth(135)
    t.fd(140)
    t.seth(225)
    t.fd(140)
    t.pu()
    t.goto(x+175,y+100)
    t.pd()
    t.seth(180)
    t.end_fill()
    t.fillcolor('light blue')
    t.begin_fill()
    for i in range(4):
        t.fd(50)
        t.left(90)
    t.end_fill()
    t.pu()
    t.goto(x+200,y+200)
    t.pd()
    t.seth(180)
    t.fd(200)
    #画小雪花
    for i in range(50):
        t.pu()
        t.goto(r.randint(-300,300), r.randint(-100,300))
        t.pd()
        t.pencolor('white')
        t.dot(10)
    def fc(cd,cen,cx):
        t.colormode(255)
        t.pencolor(102,51,0)
        if cen >= 0:
            t.speed(0)
            t.pensize(cx)
            t.fd(cd)
            t.left(15)
            c = r.randint(10,100)
            fc(c,cen-1,cx-4)
            t.right(30)
            c = r.randint(10, 100)
            fc(c, cen - 1, cx-4)
            t.left(15)
            t.bk(cd)
    t.pu()
    t.goto(100,-100)
    t.pd()
    t.seth(90)
    fc(60,4,20)
    #画非常大的雪花
    a = 0
    t.pencolor('white')
    t.pensize(10)
    for j in range(r.randint(2, 6)):
        t.pu()
        t.goto(r.randint(-300,300), r.randint(100,300))
        t.pd()
        for i in range(8):
            t.seth(a)
            t.fd(30)
            t.left(45)
            t.fd(10)
            t.fd(-10)
            t.right(90)
            t.fd(10)
            t.fd(-10)
            t.seth(a)
            t.fd(-30)
            a+=45

5.在同目录下载建一个Python文件

里面写着:

from turtle import *
from time import *
from 春天 import *
from 夏天 import *
from 秋天 import *
from 冬天 import *
while True:
    clearscreen()
    a()
    sleep(1)
    clearscreen()
    b()
    sleep(1)
    clearscreen()
    c()
    sleep(1)
    clearscreen()
    d()
    sleep(1)

运行一下它,就成功了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值