猫史档案馆


【Python作品分享】map【作品秀】

用户:优雅的乌力eFIG优雅的乌力eFIG查看:0 回复:0 评论:0 创建时间:2021-07-30T10:17:11


【作品展示】

center_image

 

【作品介绍】

作品

 

【作品源代码】

import turtle as t
import random
t.speed(300)
t.setup(700,700)
t.bgcolor('#fc6501')
def Tree():
    t.pencolor('green')
    t.fillcolor('green')
    t.begin_fill()
    t.setheading(45)
    t.backward(6)
    t.setheading(0)
    t.forward(3)
    t.setheading(45)
    t.backward(7)
    t.setheading(0)
    t.forward(13)
    t.setheading(-45)
    t.backward(7)
    t.setheading(0)
    t.forward(3)
    t.setheading(-45)
    t.backward(7)
    t.end_fill()
    t.fillcolor('brown')
    t.pencolor('brown')
    t.begin_fill()
    t.penup()
    t.setheading(-90)
    t.forward(12)
    t.pendown()
    t.setheading(180)
    t.forward(1.5)
    t.setheading(-90)
    t.forward(8.2)
    t.setheading(0)
    t.forward(4.5)
    t.setheading(90)
    t.forward(8.2)
    t.left(90)
    t.forward(2.7)
    t.end_fill()
    t.hideturtle()
def Forest(x, y):
    for r in range(5):
        for n in range(5):
            Tree()
            t.penup()
            t.setheading(-90)
            t.forward(5)
            t.pendown()
        x += 17
        t.penup()    
        t.sety(y)
        t.setx(x)
        t.pendown()
q = random.randint(1,10)
for j in range(q):
    t.penup()
    x = random.randint(-350,350)
    y = random.randint(-350,350)
    t.setx(x)
    t.sety(y)
    t.pendown()
    Forest(x,y)
t.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页