先来展示一下效果图:
不知道大家给女朋友的备注是什么?下面看看我的备注。
这是我给女朋友的备注:
再来看看给女朋友一个发射爱心的图片,这个叫“既许一人以偏爱,愿尽余生之慷慨”,
看完了发射爱心,接下来我们来一个更加高级的操作,不好,被丘比特的箭射中了,只能余生“我陪你闹,你陪我笑!”
当然作为程序员,这些效果图不可能是画出来的,进入正题,我们用的是python代码写出来的,下面先附上源代码:
import turtle
import time
# 实现清屏
def clear_screen():
turtle.penup() #画笔抬起
turtle.goto(0,0) #定位到(0,0)
turtle.color('white')
turtle.pensize(800) #画笔粗细
turtle.pendown() #画笔落下
turtle.setheading(0) #设置朝向
turtle.fd(300) #前进
turtle.bk(600) #后退
# 初始化海龟的位置
def go_start(x, y, state):
turtle.pendown() if state else turtle.penup()
turtle.goto(x, y)
#画线,state为真时海龟回到原点,为假时不回到原来的出发点
def draw_line(length, angle, state):
turtle.pensize(1)
turtle.pendown()
turtle.setheading(angle)
turtle.fd(length)
turtle.bk(length) if state else turtle.penup()
turtle.penup()
# 画出发射爱心的小人
def draw_people(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.pensize(2)
turtle.color('black')
turtle.setheading(0)
turtle.circle(35, 360)
turtle.penup()
turtle.pensize(3)
turtle.setheading(90)
turtle.fd(45)
turtle.setheading(180)
turtle.fd(20)
turtle.setheading(0)
turtle.fd(35)
turtle.pendown()
turtle.circle(4, 360)
turtle.penup()
turtle