I'm making a project where I have a turtle drawing a black line, but following it is another turtle drawing a white line. I want this white line to draw over the black line to "erase" the black line, but the black line remains above the white line.
I am programming this on trinket.io
Here's my code:
import turtle
#create elements
pen = turtle.Turtle()
follow = turtle.Turtle()
screen = turtle.Screen()
#create variables
positions = [0,-180,0,-180,0,-180,0,-180,0,-180,0,-180,0,-180,0,-180,0,-180,0,-180]
#moving functions
def move_left():
if pen.xcor() > -180:
pen.goto(pen.xcor()-10,pen.ycor())
def move_right():
if pen.xcor() < 180:
pen.goto(pen.xcor()+10,pen.ycor())
def move_up():
if pen.ycor() < 180:
pen.goto(pen.xcor(),pen.ycor()+10)
def move_down():
if pen.ycor() > -180:
pen.goto(pen.xcor(),pen.ycor()-10)
#pen setup
pen.speed(1000)
pen.penup()
pen.goto(0,-180)
pen.left(90)
pen.pendown()
follow.left(90)
follow.color("#FFFFF1")
follow.width(50)
#adjust frame refresh settings
pen.tracer(0,0)
rate = 0
refresh = 0
#game functionality
def game():
screen.onkey(move_left, 'left')
screen.onkey(move_right, 'right')
screen.onkey(move_up, 'up')
screen.onkey(move_down, 'down')
follow.goto(positions[0],positions[1])
positions.append(pen.xcor())
positions.append(pen.ycor())
positions.pop(0)
positions.pop(0)
#wait for keys
screen.listen()
#loop
while True:
game()
if refresh < rate:
refresh = refresh + 1
else:
pen.update()
#print(positions)
refresh = 0
How can I fix my program?