学习了海归画图,闲来无事,借鉴了一些代码,自己写了一个跟随鼠标移动小人

import turtle

import pyautogui
import time


class move_1():
turtle.hideturtle()
# 笔的宽度
turtle.width(10)


def draw_1(self,x,y):
#画头
# 画板
# turtle.screensize(1300, 700, "white")

# 笔的颜色
turtle.color("blue")
turtle.penup()
turtle.goto(0+x,0+y)
turtle.pendown()
# 画圆
turtle.circle(20)

#画手臂
# 抬笔,这样,路径就不会画出来
turtle.penup()
# 去坐标(120,0)
turtle.goto(0+x, y-9)
# 下笔
turtle.pendown()
turtle.color("black")
turtle.goto(x-30,10+y)
# 画手臂
turtle.penup()
turtle.goto(x+0, y-9)
turtle.pendown()
turtle.color("red")
turtle.goto(30+x,10+y)
# 画身子
turtle.penup()
turtle.goto(0+x, y-5)
turtle.pendown()
turtle.color("yellow")
turtle.goto(0+x,y-35)
# 画腿
turtle.penup()
turtle.goto(0+x, -35+y)
turtle.pendown()
turtle.color("green")
turtle.goto(x-20,y-80)
# 画腿
turtle.penup()
turtle.goto(0 + x, -35 + y)
turtle.pendown()
turtle.color("green")
turtle.goto(x + 20, y - 80)



if __name__ == '__main__':
x=0
y=0
while True:
turtle.clear()
m1 = move_1()

print(x,y)
m1.draw_1(x, y)
time.sleep(1)
x, y = pyautogui.position()
x=x-660
y=340-y

猜你喜欢

转载自www.cnblogs.com/huhaitao/p/11459965.html