Free Friday 11/14

I made a heart using turtle

import turtle
import time


screen = turtle.Screen()
screen.bgcolor("black")

leo = turtle.Turtle()
leo.speed(0)
leo.hideturtle()

def draw_heart(x, y):
    leo.penup()
    leo.goto(x, y)
    leo.pendown()
    leo.color("red", "pink")
    leo.begin_fill()
    leo.left(50)
    leo.forward(133)
    leo.circle(50, 200)
    leo.right(140)
    leo.circle(50, 200)
    leo.forward(133)
    leo.end_fill()
    leo.setheading(0)  # reset orientation


x = -200
direction = 5

while True:
    leo.clear()
    draw_heart(x, -50)
    x += direction
    if x > 200 or x < -200:  
        direction *= -1
    time.sleep(0.05)

turtle.mainloop()

It makes a heart and move it


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *