栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

使用python绘制城堡

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用python绘制城堡

import turtle as t
def triangle(a,b,c):
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor('purple')
    t.begin_fill()
    t.forward(c)
    t.left(120)
    t.forward(c)
    t.left(120)
    t.forward(c)
    t.left(120)
    t.end_fill()
def square(a,b,c,d):
    #a,b为坐标;c为底部宽,d为长
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor("#cec2d6")
    t.begin_fill()
    t.forward(c)
    t.left(90)
    t.forward(d)
    t.left(90)
    t.forward(c)
    t.left(90)
    t.forward(d)
    t.left(90)
    t.end_fill()
def wall(a,b,c,d):
    #a,b为坐标;c为底部宽,d为长
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor("#cec2d6")
    t.begin_fill()
    t.forward(c)
    t.left(90)
    t.forward(d)
    for i in range(0,4,1):
        t.left(90)
        t.forward(10)
        t.left(90)
        t.forward(10)
        t.right(90)
        t.forward(10)
        t.right(90)
        t.forward(10)
    t.left(90)
    t.forward(10)
    t.left(90)
    t.forward(d)
    t.left(90)
    t.end_fill()
def downwall(a,b,c,d):
        #a,b为坐标;c为底部宽,d为长
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor("#cec2d6")
    t.begin_fill()
    t.forward(c)
    t.left(90)
    t.forward(d)
    for i in range(0,5,1):
        t.left(90)
        t.forward(10)
        t.left(90)
        t.forward(10)
        t.right(90)
        t.forward(10)
        t.right(90)
        t.forward(10)
    t.left(90)
    t.forward(10)
    t.left(90)
    t.forward(d)
    t.left(90)
    t.end_fill()
def floor(a,b):
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor("purple")
    t.begin_fill()
    t.forward(50)
    t.left(90)
    t.forward(20)
    for i in range(0,2,1):
        t.left(90)
        t.forward(10)
        t.left(90)
        t.forward(10)
        t.right(90)
        t.forward(10)
        t.right(90)
        t.forward(10)
    t.left(90)
    t.forward(10)
    t.left(90)
    t.forward(20)
    t.left(90)
    t.end_fill()
def decoration(a,b):
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor("black")
    t.begin_fill()
    t.forward(10)
    t.left(90)
    t.forward(10)
    t.circle(5,180)
    t.forward(10)
    t.end_fill()
    t.left(90)
def decoration1(a,b):
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor("black")
    t.begin_fill()
    t.forward(8)
    t.left(90)
    t.forward(8)
    t.circle(4,180)
    t.forward(8)
    t.end_fill()
    t.left(90)
def door(a,b):
    t.penup()
    t.goto(a,b)
    t.pendown()
    t.fillcolor("black")
    t.begin_fill()
    t.forward(20)
    t.left(90)
    t.forward(20)
    t.circle(10,180)
    t.forward(20)
    t.end_fill()
    t.left(90)
t.pensize(3)
t.pencolor("black")
square(-30,90,20,40)
square(10,90,20,30)

wall(-45,0,90,100)
square(-85,-60,30,30)
square(55,-60,30,30)
square(-75,-20,30,50)
square(45,-20,30,50)
door(0,0)
downwall(-55,-60,110,70)
floor(-105,-30)
floor(55,-30)
triangle(-75,30,30)
triangle(45,30,30)
triangle(-30,130,20)
triangle(10,120,20)
decoration(10,70)
decoration(10,40)
decoration(-20,60)
decoration1(-64,10)
decoration1(60,10)
decoration1(-22.5,110)
decoration1(14.5,100)
door(-10,-60)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/844531.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号