用python写一个冰墩墩,大家安装一个python的环境就可以玩了,下面是代码

用python写一个冰墩墩,大家安装一个python的环境就可以玩了,下面是代码:

import time
import turtle

turtle.title('冰墩墩')
# 速度
turtle.speed(1000)

class BingDwenDwen:
    def pen(self, dict):
        turtle.penup()
        turtle.goto(dict[0], dict[1])
        turtle.pencolor(dict[2])
        turtle.pensize(dict[3])
        turtle.fillcolor(dict[4])
        turtle.begin_fill()
        turtle.pendown()

    def pen1(self, dict_1):
        turtle.penup()
        turtle.goto(dict_1[0], dict_1[1])
        turtle.fillcolor(dict_1[2])
        turtle.begin_fill()
        turtle.setheading(dict_1[3])
        turtle.pendown()

    def left_hand(self, dict, hand):
        self.pen(dict)
        turtle.setheading(80)
        self.circle(hand)
        turtle.end_fill()

    def left_hand_fill(self, dict):
        self.pen(dict)
        turtle.setheading(95)
        self.circle(dict_left_hand[1])
        turtle.end_fill()

    def circle(self, dict):
        for i in dict:
            turtle.circle(i[0], i[1])

    def body(self, dict, dict1):
        turtle.penup()
        self.pen(dict)
        turtle.setheading(20)
        turtle.circle(-250, 35)
        # 左耳
        turtle.setheading(50)
        turtle.circle(-42, 180)
        # 左侧
        turtle.setheading(-50)
        turtle.circle(-190, 30)
        turtle.circle(-320, 45)
        # 左右腿
        self.circle(dict1)
        # 右手
        turtle.setheading(-120)
        self.circle(dict_right_hand[0])
        # 右侧
        turtle.setheading(86)
        turtle.circle(-300, 26)
        # 右耳
        turtle.setheading(122)
        turtle.circle(-53, 160)
        turtle.end_fill()

    def right_ear_fill(self, dict):
        self.pen(dict)
        turtle.setheading(120)
        turtle.circle(-28, 160)
        turtle.setheading(210)
        turtle.circle(150, 20)
        turtle.end_fill()

    def left_ear_fill(self):
        turtle.penup()
        turtle.goto(90, 230)
        turtle.setheading(40)
        turtle.begin_fill()
        turtle.pendown()
        turtle.circle(-30, 170)
        turtle.setheading(125)
        turtle.circle(150, 23)
        turtle.end_fill()

    def right_hand_fill(self, dict):
        self.pen1(dict)
        self.circle(dict_right_hand[1])
        turtle.setheading(-90)
        turtle.circle(300, 14)
        turtle.end_fill()

    def left_leg_fill(self, dict, dict1):
        self.pen1(dict1)
        self.circle(dict)
        turtle.setheading(42)
        turtle.circle(-200, 29)
        turtle.end_fill()

    def right_leg_fill(self, dict, dict1):
        self.pen1(dict1)
        self.circle(dict)
        turtle.setheading(-14)
        turtle.circle(-200, 27)
        turtle.end_fill()

    def eyes(self, dict, dict1):
        self.pen1(dict)
        self.circle(dict1)
        turtle.end_fill()

    def eyes_fill(self, dict):
        for i in dict:
            turtle.penup()
            turtle.goto(i[0], i[1])
            turtle.pencolor(i[2])
            turtle.fillcolor(i[2])
            turtle.begin_fill()
            turtle.pendown()
            turtle.setheading(0)
            turtle.circle(i[3], i[4])
            turtle.end_fill()

    def nose(self, dict):
        turtle.penup()
        turtle.goto(37, 80)
        turtle.fillcolor("black")
        turtle.begin_fill()
        turtle.pendown()
        self.circle(dict)
        turtle.end_fill()

    def mouse(self):
        turtle.penup()
        turtle.goto(-15, 48)
        turtle.setheading(-36)
        turtle.begin_fill()
        turtle.pendown()
        turtle.circle(60, 70)
        turtle.setheading(-132)
        turtle.circle(-45, 100)
        turtle.end_fill()

    def rainbow(self, dict):
        turtle.penup()
        for i in dict:
            turtle.goto(i[0][0], i[0][1])
            turtle.pensize(5)
            turtle.pencolor(i[0][2])
            turtle.pendown()
            turtle.setheading(60)
            self.circle(i[1])

    def heart(self, dict):
        self.pen(dict)
        turtle.setheading(36)
        turtle.circle(-8, 180)
        turtle.circle(-60, 24)
        turtle.setheading(110)
        turtle.circle(-60, 24)
        turtle.circle(-8, 180)
        turtle.end_fill()

    def rings(self, dict):
        for i in dict:
            turtle.penup()
            turtle.goto(i[0], i[1])
            turtle.pendown()
            turtle.pencolor(i[2])
            turtle.circle(6)

        turtle.penup()
        turtle.pencolor("black")
        turtle.goto(-16, -160)
        
        turtle.write("黄庆傻der!", font=('Arial', 10, 'bold italic'))
        turtle.hideturtle()
        turtle.done()


if __name__ == '__main__':
    dict = [(177, 112, "lightgray", 3, "white"),
            (182, 95, "black", 1, "black"),
            (-73, 230, "lightgray", 3, "white"),
            (-130, 180, "black", 1, "black"),
            (220, 115, "brown", 1, "brown")]
    dict_1 = [(-180, -55, "black", -120),
              (108, -168, "black", -115),
              (-38, -210, "black", -155),
              (-64, 120, "black", 40),
              (51, 82, "black", 120)]
    # 左手
    dict_left_hand = [[(-45, 200), (-300, 23)],
                      [(-37, 160), (-20, 50), (-200, 30)]]
    # 右手
    dict_right_hand = [[(50, 30), (-35, 200), (-300, 23)],
                       [(50, 30), (-27, 200), (-300, 20)]]
    # 左右腿
    dict1 = [(120, 30),
             (200, 12),
             (-18, 85),
             (-180, 23),
             (-20, 110),
             (15, 115),
             (100, 12),
             (15, 120),
             (-15, 110),
             (-150, 30),
             (-15, 70),
             (-150, 10),
             (200, 35),
             (-150, 20)]
    # 左右腿填充
    dict2 = [[(110, 15), (200, 10), (-18, 80), (-180, 13), (-20, 90), (15, 60)],
             [(15, 100), (-10, 110), (-100, 30), (-15, 65), (-100, 10), (200, 15)]]
    # 左右眼圈
    dict4 = [[(-35, 152), (-100, 50), (-35, 130), (-100, 50)],
             [(-32, 152), (-100, 55), (-25, 120), (-120, 45)]]
    # 左右眼珠
    dict5 = [
        [(-47, 55, "white", 25, 360),
         (-45, 62, "darkslategray", 19, 360),
         (-45, 68, "black", 10, 360),
         (-47, 86, "white", 5, 360)],
        [(79, 60, "white", 24, 360),
         (79, 64, "darkslategray", 19, 360),
         (79, 70, "black", 10, 360),
         (79, 88, "white", 5, 360)]
    ]
    # 鼻子
    dict6 = [(-8, 130), (-22, 100), (-8, 130)]
    # 彩虹圈
    dict7 = [[(-135, 120, "cyan"), [(-165, 150), (-130, 78), (-250, 30), (-138, 105)]],
             [(-131, 116, "slateblue"), [(-160, 144), (-120, 78), (-242, 30), (-135, 105)]],
             [(-127, 112, "orangered"), [(-155, 136), (-116, 86), (-220, 30), (-134, 103)]],
             [(-123, 108, "gold"), [(-150, 136), (-104, 86), (-220, 30), (-126, 102)]],
             [(-120, 104, "greenyellow"), [(-145, 136), (-90, 83), (-220, 30), (-120, 100)]]]
    # 五环
    dict8 = [(-5, -170, "blue"),
             (10, -170, "black"),
             (25, -170, "brown"),
             (2, -175, "lightgoldenrod"),
             (16, -175, "green")]
    BingDwenDwen = BingDwenDwen()
    BingDwenDwen.left_hand(dict[0], dict_left_hand[0])
    BingDwenDwen.left_hand_fill(dict[1])
    BingDwenDwen.body(dict[2], dict1)
    BingDwenDwen.right_ear_fill(dict[3])
    BingDwenDwen.left_ear_fill()
    BingDwenDwen.right_hand_fill(dict_1[0])
    BingDwenDwen.left_leg_fill(dict2[0], dict_1[1])
    BingDwenDwen.right_leg_fill(dict2[1], dict_1[2])
    BingDwenDwen.eyes(dict_1[3], dict4[0])
    BingDwenDwen.eyes_fill(dict5[0])
    BingDwenDwen.eyes(dict_1[4], dict4[1])
    BingDwenDwen.eyes_fill(dict5[1])
    BingDwenDwen.nose(dict6)
    BingDwenDwen.mouse()
    BingDwenDwen.rainbow(dict7)
    BingDwenDwen.heart(dict[4])
    BingDwenDwen.rings(dict8)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,907评论 6 506
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,987评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,298评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,586评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,633评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,488评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,275评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,176评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,619评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,819评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,932评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,655评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,265评论 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,871评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,994评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,095评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,884评论 2 354

推荐阅读更多精彩内容