一、哆啦A夢 由於代碼過長,這裡僅顯示部分代碼: from turtle import * import turtle as t from random import * #五軌跡跳躍 def my_goto(x,y): penup() goto(x,y) pendown() def eyes(): ...
一、哆啦A夢
由於代碼過長,這裡僅顯示部分代碼:
from turtle import * import turtle as t from random import * #五軌跡跳躍 def my_goto(x,y): penup() goto(x,y) pendown() def eyes(): fillcolor('#ffffff') begin_fill() tracer(False) a = 2.5 for i in range(120): if 0<= i<30 or 60 <= i <90: a -= 0.05 lt(3) fd(a) else: a += 0.05 lt(3) fd(a) tracer(True) end_fill() #鬍鬚 def beard(): my_goto(-32,135) seth(165) fd(60) my_goto(-32,125) seth(180) fd(60) my_goto(-32,115) seth(193) fd(60) my_goto(37,135) seth(15) fd(60) my_goto(37,125) seth(0) fd(60) my_goto(37,115) seth(-13) fd(60) #嘴巴 def mouth(): my_goto(5,148) seth(270) fd(100) seth(0) circle(120,50) seth(230) circle(-120,100)
二、海綿寶寶
部分代碼如下:
from turtle import * def go_to(x, y): penup() goto(x, y) pendown() def help_do(): go_to(-400, 0) forward(800) go_to(-400, 100) forward(800) go_to(-400,200) forward(800) go_to(-400, -100) forward(800) go_to(-400, -200) forward(800) left(90) go_to(0,-300) forward(600) go_to(100, -300) forward(600) go_to(-100, -300) forward(600) go_to(-200, -300) forward(600) go_to(200, -300) forward(600) def head(): go_to(-200, 180) fillcolor('yellow') begin_fill() seth(-30) for _ in range(6): circle(36, 60) circle(-36, 60) seth(-125) for _ in range(5): circle(40,60) circle(-40,60) seth(-210) for _ in range(4): circle(45,60) circle(-45,60) seth(65) for _ in range(5): circle(40,60) circle(-40,60) end_fill()
三、皮卡丘
部分代碼如下:
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()
四、史迪仔
部分代碼如下:
from turtle import * setup(650,650) penup() pensize(5) speed(1000) pencolor("#065693") seth(180) fd(140) seth(-90) fd(50) pendown() #起點 fillcolor("#0079C6") begin_fill() seth(170) circle(-40,100) seth(180) fd(50) seth(180) circle(-10,46) seth(130) circle(-300,40)#耳朵外廓大圓 circle(-100,45) right(10) circle(-50,30) right(10) circle(-30,30) left(1) fd(2) right(1) fd(3) right(4) fd(3) right(3) fd(5) right(4) fd(6) right(4) fd(10) right(4) fd(10) right(3) fd(15) right(2) fd(20) right(2) fd(20) right(4) fd(20) right(3) fd(30) right(1) fd(40) right(1) fd(60) seth(-115) fd(5) #臉左側開始逆時針 circle(200,30) end_fill() begin_fill() left(8) fd(20) left(10) fd(20) left(14) circle(100,30) left(10) circle(150,20) right(2) fd(55) left(5) fd(40) left(3) fd(25) right(3) circle(150,20) left(7) circle(100,30)
五、完整源碼下載
關註我的原創公眾號【小鴻愛摸魚】,回覆【可愛皮卡丘】、【哆啦A夢】、【史迪仔】、【海綿寶寶】關鍵詞獲取對應的源碼
六、作者Info
Author:南柯樹下,Goal:讓編程更有趣!
原創微信公眾號:『小鴻愛摸魚』,專註於演算法、爬蟲,網站,游戲開發,數據分析、自然語言處理,AI等,期待你的關註,讓我們一起成長、一起Coding!
版權聲明:本文禁止抄襲、轉載 ,侵權必究!
—— —— —— —— — END —— —— —— —— ————
歡迎掃碼關註我的公眾號
小鴻愛摸魚