使用Python写一个皮卡丘

import turtle


def getPosition(x, y):
    turtle.setx(x)
    turtle.sety(y)
    print(x, y)


class Pikachu:

    def __init__(self):
        self.t = turtle.Turtle()
        t = self.t
        t.pensize(3)
        t.speed(9)
        t.ondrag(getPosition)

    def noTrace_goto(self, x, y):
        self.t.penup()
        self.t.goto(x, y)
        self.t.pendown()

    def leftEye(self, x, y):
        self.noTrace_goto(x, y)
        t = self.t
        t.seth(0)
        t.fillcolor('#333333')
        t.begin_fill()
        t.circle(22)
        t.end_fill()

        self.noTrace_goto(x, y + 10)
        t.fillcolor('#000000')
        t.begin_fill()
        t.circle(10)
        t.end_fill()

        self.noTrace_goto(x + 6, y + 22)
        t.fillcolor('#ffffff')
        t.begin_fill()
        t.circle(10)
        t.end_fill()

    def rightEye(self, x, y):
        self.noTrace_goto(x, y)
        t = self.t
        t.seth(0)
        t.fillcolor('#333333')
        t.begin_fill()
        t.circle(22)
        t.end_fill()

        self.noTrace_goto(x, y + 10)
        t.fillcolor('#000000')
        t.begin_fill()
        t.circle(10)
        t.end_fill()

        self.noTrace_goto(x - 6, y + 22)
        t.fillcolor('#ffffff')
        t.begin_fill()
        t.circle(10)
        t.end_fill()

    def mouth(self, x, y):
        self.noTrace_goto(x, y)
        t = self.t

        t.fillcolor('#88141D')
        t.begin_fill()
        # 下嘴唇
        l1 = []
        l2 = []
        t.seth(190)
        a = 0.7
        for i in range(28):
            a += 0.1
            t.right(3)
            t.fd(a)
            l1.append(t.position())

        self.noTrace_goto(x, y)

        t.seth(10)
        a = 0.7
        for i in range(28):
            a += 0.1
            t.left(3)
            t.fd(a)
            l2.append(t.position())

        # 上嘴唇

        t.seth(10)
        t.circle(50, 15)
        t.left(180)
        t.circle(-50, 15)

        t.circle(-50, 40)
        t.seth(233)
        t.circle(-50, 55)
        t.left(180)
        t.circle(50, 12.1)
        t.end_fill()

        # 舌头
        self.noTrace_goto(17, 54)
        t.fillcolor('#DD716F')
       

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,我可以回答这个问题。以下是一个使用Python皮卡丘程序: ```python import turtle # 设置画布大小和背景颜色 turtle.setup(800, 600) turtle.bgcolor('#FEE12B') # 画皮卡丘的头部 turtle.penup() turtle.goto(-200, 100) turtle.pendown() turtle.begin_fill() turtle.color('#F8A91B') turtle.circle(100) turtle.end_fill() # 画皮卡丘的眼睛 turtle.penup() turtle.goto(-140, 180) turtle.pendown() turtle.begin_fill() turtle.color('#FFFFFF') turtle.circle(30) turtle.end_fill() turtle.penup() turtle.goto(-140, 200) turtle.pendown() turtle.begin_fill() turtle.color('#000000') turtle.circle(10) turtle.end_fill() turtle.penup() turtle.goto(-60, 180) turtle.pendown() turtle.begin_fill() turtle.color('#FFFFFF') turtle.circle(30) turtle.end_fill() turtle.penup() turtle.goto(-60, 200) turtle.pendown() turtle.begin_fill() turtle.color('#000000') turtle.circle(10) turtle.end_fill() # 画皮卡丘的鼻子 turtle.penup() turtle.goto(-100, 120) turtle.pendown() turtle.begin_fill() turtle.color('#FF7F50') turtle.circle(20) turtle.end_fill() # 画皮卡丘的嘴巴 turtle.penup() turtle.goto(-120, 80) turtle.pendown() turtle.color('#000000') turtle.right(90) turtle.circle(120, 90) # 画皮卡丘的脸颊 turtle.penup() turtle.goto(-200, 0) turtle.pendown() turtle.begin_fill() turtle.color('#F8A91B') turtle.circle(80) turtle.end_fill() turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.begin_fill() turtle.color('#F8A91B') turtle.circle(80) turtle.end_fill() # 画皮卡丘的耳朵 turtle.penup() turtle.goto(-200, 200) turtle.pendown() turtle.begin_fill() turtle.color('#F8A91B') turtle.right(45) turtle.circle(60, 90) turtle.right(180) turtle.circle(-60, 90) turtle.end_fill() turtle.penup() turtle.goto(0, 200) turtle.pendown() turtle.begin_fill() turtle.color('#F8A91B') turtle.left(45) turtle.circle(-60, 90) turtle.left(180) turtle.circle(60, 90) turtle.end_fill() # 画皮卡丘的手臂 turtle.penup() turtle.goto(-200, -100) turtle.pendown() turtle.begin_fill() turtle.color('#F8A91B') turtle.right(45) turtle.circle(60, 90) turtle.right(180) turtle.circle(-60, 90) turtle.end_fill() turtle.penup() turtle.goto(0, -100) turtle.pendown() turtle.begin_fill() turtle.color('#F8A91B') turtle.left(45) turtle.circle(-60, 90) turtle.left(180) turtle.circle(60, 90) turtle.end_fill() # 画皮卡丘的脚 turtle.penup() turtle.goto(-150, -250) turtle.pendown() turtle.begin_fill() turtle.color('#000000') turtle.circle(50) turtle.end_fill() turtle.penup() turtle.goto(50, -250) turtle.pendown() turtle.begin_fill() turtle.color('#000000') turtle.circle(50) turtle.end_fill() turtle.done() ``` 希望这个程序能够帮助你!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

!浩瀚 !

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值