Advertisement
Guest User

Untitled

a guest
May 26th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement