设为首页 加入收藏

TOP

教你用Python画个可爱的皮卡丘!(附完整源码)
2023-07-23 13:45:12 】 浏览:19
Tags:Python 皮卡丘

版权声明:原创不易,本文禁止抄袭、转载,侵权必究!

 

一、去吧!皮卡丘!

使用turtle(海龟库)制作而成,感觉挺好玩的,哈哈@>_<@,效果如下:

 

由于源码过长,这里仅展示部分代码:

from turtle import *
import turtle as t
from random import *


def infoPrt():
    print('coordinate: ' + str(t.pos()))
    print('angle: ' + str(t.heading()))

t.pensize(3)
t.hideturtle()
t.colormode(255)
t.color("black")
t.setup(700, 650)
t.speed(1)
t.st()
t.pu()
t.goto(-210,86)
t.pd()
infoPrt()

#
print('')
t.seth(85)
t.circle(-100,50)
infoPrt()
t.seth(25)
t.circle(-170,50)
infoPrt()

# 右耳
print('右耳')
t.seth(40)
t.circle(-250,30)
infoPrt()

# 右耳尖
t.begin_fill()

#
t.circle(-250,22)

#
t.seth(227)
t.circle(-270, 15)
prePos = t.pos()
infoPrt()

#
t.seth(105)
t.circle(100, 32)
t.end_fill()
t.pu()
t.setpos(prePos)
t.pd()
t.seth(212)
t.circle(-270, 28)
prePos = t.pos()
t.pu()
t.goto(t.xcor()+5,t.ycor()-2)
t.pd()

# 躯干
print('躯干')
t.seth(280)
t.circle(500, 30)
infoPrt()

# 臀部
print('臀部')
t.seth(120)
t.circle(150, -11)
p_tail=t.pos()
t.circle(150, -44)
p_butt=t.pos()
infoPrt()

# 尾巴
t.pu()
t.setpos(p_tail)
t.pd()
t.begin_fill()
t.seth(50)
t.fd(25)
t.seth(-50)
t.fd(30)
p_tail1=t.pos
t.seth(-140)
t.fd(36)
t.end_fill()
t.seth(39)

 

想要学习turtle(海龟库)的同志可以看官方教程文档:

https://docs.python.org/3.9/library/turtle.html

 


 

四、完整源码下载

关注我的原创公众号【小鸿爱摸鱼】,回复【皮卡丘】关键词获取完整源码

 


 

五、作者Info

Author:南柯树下,Goal:让编程更有趣!

原创微信公众号:『小鸿爱摸鱼』,专注于算法、爬虫,数据分析、自然语言处理,机器学习等,期待你的关注,让我们一起成长、一起Coding!

版权声明:本文禁止抄袭、转载 ,侵权必究!

 

—  ——  ——  ——  —  END  ——  ——  ——  ——  ———— 

         欢迎扫码关注我的公众号

          小鸿爱摸鱼

       


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Pycharm 简介 下一篇python爬虫,requests使用,网页..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目