SHARE
TWEET

Untitled

a guest May 26th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from turtle import Turtle, Screen
  2. xmax=250
  3. ymax=250
  4. file = open("testfile.txt","w")
  5. def konec():
  6.    print("konec")
  7.    t.bye()
  8. def tazeni(x, y):
  9.     t.ondrag(None)
  10.     t.setheading(t.towards(x, y))
  11.     if abs(x)>xmax and x>0:
  12.         x=xmax
  13.     if abs(x)>xmax and x<0:
  14.         x=xmax*-1
  15.     if abs(y)>ymax and y>0:
  16.         y=xmax
  17.     if abs(y)>ymax and y<0:
  18.         y=xmax*-1
  19.     print("x",x,"y",y)    
  20.     t.goto(x, y)
  21.     #t.onkey(konec, "q")
  22.     t.ondrag(tazeni)
  23.  
  24. obrazovka = Screen()
  25. obrazovka.setup(2*xmax+20,2*ymax+20)
  26. t = Turtle('turtle')
  27. t.speed('fastest')
  28. t.ondrag(tazeni)
  29.  
  30. obrazovka.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top