(Python) Why I get the turtle.Terminator error in this code?

import turtle
import random
import time

width=800
height=800

scr=turtle.Screen()
scr.title('tryofgame')
scr.setup(width,height)

a=5
b=20
t=turtle.Turtle()
t.speed(0)
t.pensize(a)
t.penup()

colors=('red','blue','green','orange','yellow')
shapes=('arrow','turtle','triangle','square')

def tr(y,x):
  y.right(x)
def tf(y,x):
  y.forward(x)
def tl(y,x):
  y.left(x)
def tb(y,x):
  y.backward(x)
def pu(x):
  x.penup()
def pd(x):
  x.pendown()
#movementoprota
def up():
  t.setheading(90)
  tf(t, b)
def down():
  t.setheading(270)
  tf(t, b)
def left():
  t.setheading(180)
  tf(t, b)
def right():
  t.setheading(0)
  tf(t, b)
#movemetn finish
def ckl(x,y):
    t.color(random.choice(colors))
def ckr(x,y):
    t.stamp()
    xx=t.xcor()
    yy=t.ycor()
    print(round(xx))
    print(round(yy))
    print('')


#I think the problem is here:

scr.listen()

scr.onscreenclick(ckl,1) 
scr.onscreenclick(ckr,3) 
scr.onkey(up,'Up')
scr.onkey(up,'w')
scr.onkey(down,'Down')
scr.onkey(down,'s')
scr.onkey(left,'Left')
scr.onkey(left,'a')
scr.onkey(right,'Right')
scr.onkey(right,'d')

scr.update
rdp=random.randint(-300,300)
rdp2=random.randint(-300,300)
print(rdp)
print(rdp2)
z=1
#please workkkkk
true=True
while true:
      dz=turtle.Turtle()
      dz.ht()
      dz.color('cyan')
      dz.pensize(5) 
      dz.penup()
      dz.setpos(rdp,rdp2)
      dz.pendown()
      dz.left(90)
      dz.forward(75)
      dz.left(90)
      dz.forward(100)
      dz.left(90)
      dz.forward(75)
      if t.ycor() in range(rdp2,rdp2+80) and t.xcor() in range(rdp-100,rdp):
        print('YOU WOOOOONNNN!')
        z+=1
        rdp=random.randint(-300,300)
        rdp2=random.randint(-300,300)
        dz=turtle.Turtle()
        dz.ht()
        dz.color('cyan')
        dz.pensize(5) 
        dz.penup()
        dz.setpos(rdp,rdp2)
        dz.pendown()
        dz.left(90)
        dz.forward(75)
        dz.left(90)
        dz.forward(100)
        dz.left(90)
        dz.forward(75)
        if t.ycor() in range(rdp2,rdp2+80) and t.xcor() in range(rdp-100,rdp):
          print('YOU WOOOOONNNN!')
          z+=1
      scr.update()
    

scr.mainloop()

That is the code i wrote to make like a game but I don´t know why sometimes it stops and it always tell me i have the terminator error but I don’t know why.Preformatted text

Hello!

Please improve the code formatting. Use the pre formatted text button on the editor:

  • Highlight the code and then click on the button (or press Control + Shift + C).

And please, indent the code.

Finally, you don’t mention a language, but is this Python?

1 Like

Thank you for telling me, Im new in this type of forums but I think I can improve with help.
Yeah this is python.